Improve the new "custom module/element templates" feature (see #4547)