<ismodule> turns a template into a tag. Custom tags complete with their attributes, open their template on Cmd+Click and show their usages, like the built-in tags
Cmd+Click on the tag opens the module template, where the attributes arrive as pdict membersDeclaring a custom tag
An <ismodule> maps a tag name to a template and lists its attributes:
<ismodule template="product/loyaltyBadge"
name="loyaltybadge"
attribute="product"
attribute="size"
/>This declares <isloyaltybadge>. Its attributes reach product/loyaltyBadge.isml as pdict.product and pdict.size, in lower case. A template includes the modules file before it uses the tag:
<isinclude template="util/modules" />
<isloyaltybadge product="${product}" />Multi-line declarations and single-quoted or unquoted values count, declarations inside <iscomment> don't
Which declarations a template sees
This template
Its own <ismodule> declarations before the usage, the nearest first
Included templates
Declarations in the templates it includes before the usage
Modules files
Declarations in the modules files of the linked cartridges, in cartridge order, visible in every template
Modules files are named modules.isml or module.isml, or as set in Settings › Languages & Frameworks › ISML › Modules files. An empty field reads intellij-sfcc.isml.modules.files from .vscode/settings.json. A modules.isml file shows the icon in the Project view
Completion and navigation
| Where | What you get |
|---|---|
After < | is plus each declared name, such as isloyaltybadge, with the module template as type text |
| Inside the tag | The declared attributes not yet written |
| On the tag name | Cmd+Click or Go to Declaration (Cmd+B, Ctrl+B) on the start or end tag opens the module template |
| On an attribute | Go to Declaration opens the attribute line of the <ismodule> |
| Go to Symbol | Cmd+Alt+O (Ctrl+Alt+Shift+N) finds a declaration by its tag name, such as isloyaltybadge |
Renaming a declaration's name renames every usage, keeping the is prefix. In the module template, attributes are pdict members typed by the @param lines, see Scripting in ISML
Usages
| Marker | Where | Shows | Click |
|---|---|---|---|
The name of an <ismodule> | <isloyaltybadge> is used in 3 templates | Usages of <isloyaltybadge> lists the templates | |
| 4 usages | Above each <ismodule> | How many times the tag is used | Lists the templates |
| A custom tag in a template | Open the template of <isloyaltybadge> | Opens the module template |
The marker on custom tag usages is off by default, see Settings › Editor › General › Gutter Icons. The usage count is in the ISML group of Settings › Editor › Inlay Hints › Code vision. Find Usages on a template lists Declared as custom tag and Custom tag usage groups
@param check
A module template documents its attributes with @param lines in its first <iscomment>, written like @pdict lines. Custom tag @param does not match the ismodule attributes compares them with the declaration, as weak warnings:
| Message | Where | Fixes |
|---|---|---|
<isloyaltybadge> does not declare attribute 'size' | The @param name | Add 'size' to the <ismodule> declaration, Remove '@param size' |
No @param for attribute 'size' of <isloyaltybadge> | The <iscomment> | Add '@param' for 'size', which writes @param {*} size |
Unknown custom tags
Unknown ISML custom tag reports a tag the template can't see:
| Message | Fixes |
|---|---|
Unknown custom tag <isloyaltybage>: no <ismodule> declares it | Change to <isloyaltybadge> for a close name, Declare <isloyaltybage> in a modules file, Declare <isloyaltybage> and create components/loyaltybage.isml |
<isloyaltybadge> is used before its <ismodule> declaration | None. Move the <ismodule> above the first use |
<isloyaltybadge> is declared in util/badges.isml, which this template does not include | Include 'util/badges' |
Custom tag declared only in an including template (off by default) reports <isloyaltybadge> is declared only in product/productTile.isml, which includes this template and offers Declare <isloyaltybadge> in this template
Extract Custom Tag
Select template text and choose Refactor › Extract › Custom Tag... (or Refactor This, Ctrl+T, Ctrl+Alt+Shift+T):
| Field | Default |
|---|---|
| Tag name | newtag, called as <isnewtag> |
| Template | components/newtag, following the tag name until you edit it. Relative to templates/<locale> of this cartridge, without .isml |
| Declare in | Modules file (the cartridge's modules file or a new util/modules.isml), or This template (top of the current file) |
The preview shows the call, the declaration and the new template. Variables the selection reads become lower-case attributes in order of first use, read as pdict.<attribute> in the new template:
<isset name="title" value="${pdict.title}" scope="page" />
<isloop items="${pdict.products}" var="product" status="loopState">
<div class="tile ${loopState.first ? 'first' : ''}">
<span>${product.name}</span>
<span>${pdict.currencyCode} ${title}</span>
</div>
</isloop>Request-scoped variables stay as they are, since the new template sees them. For a plain <isinclude>, see Extract Include File
Completion, links, usage counts, the @param and unknown tag checks and Extract Custom Tag need a license. Highlighting works without one. Renaming a declaration doesn't rename the declarations of the same tag in other cartridges