SFCC lets you define reusable custom tags with <ismodule>. The ISML server indexes these declarations, so your custom tags complete with their attributes and link to the template they render, like the built-in tags
Declaring a custom tag
An <ismodule> declaration maps a tag name to a template and lists the attributes the tag accepts:
<ismodule template="components/productTile"
name="producttile"
attribute="product"
attribute="class"
/>This declares <isproducttile>. Its product and class attributes reach components/productTile.isml as pdict.product and pdict.class. At runtime, a template includes the module file before it uses the tag:
<isinclude template="util/modules" />
<isproducttile product="${pdict.product}" class="grid-tile" />Write the name, template, and attribute values in double quotes, because the server reads only double-quoted values. A declaration can span several lines
Discovery
The server scans every cartridge for module files and records each declaration's name, template, and attribute list. By default, module files are the templates named modules.isml or module.isml. Adding, editing, or deleting a module file updates the tags without a restart, and the tags are available in every template
Change which file names count as module files with intellij-sfcc.isml.modules.files. The list replaces the default, so keep the default names you still use:
{
"intellij-sfcc.isml.modules.files": ["modules.isml", "module.isml", "brandmodules.isml"]
}A changed list applies at once: the server reads the listed module files again, with no reload. See Linter and custom tags
What you get
- Tag completion -
isplus the declared name, such asisproducttile, appears in the tag list - Attribute completion - inside the tag, the declared attributes complete, skipping the ones already on the tag
- Link to the template - the tag name is a link to the module's template, see below
- Tag color - the tag takes the ISML tag color, like the built-in tags
Custom tags have no hover documentation, and their attributes are not validated
Open a custom tag's template
Cmd-click a custom tag name (Ctrl-click on Windows and Linux) to open the template named in its <ismodule>. When that template exists in more than one cartridge, the Select ISML File quick pick asks which copy to open, as it does for template paths. A tag gets a link only when its module template exists in an indexed cartridge