Skip to Content

Custom Tags

ISML custom tags in JetBrains IDEs - ismodule lookup, completion, navigation, usage counts, @param checks and Extract Custom Tag

<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

Custom tags complete next to the built-in tags with their module template as the type text, and their declared attributes complete inside the tag. Cmd+Click on the tag opens the module template, where the attributes arrive as pdict members

Declaring a custom tag

An <ismodule> maps a tag name to a template and lists its attributes:

util/modules.isml
<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:

product/productTile.isml
<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

WhereWhat you get
After <is plus each declared name, such as isloyaltybadge, with the module template as type text
Inside the tagThe declared attributes not yet written
On the tag nameCmd+Click or Go to Declaration (Cmd+B, Ctrl+B) on the start or end tag opens the module template
On an attributeGo to Declaration opens the attribute line of the <ismodule>
Go to SymbolCmd+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

MarkerWhereShowsClick
The name of an <ismodule><isloyaltybadge> is used in 3 templatesUsages of <isloyaltybadge> lists the templates
4 usagesAbove each <ismodule>How many times the tag is usedLists the templates
A custom tag in a templateOpen 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:

MessageWhereFixes
<isloyaltybadge> does not declare attribute 'size'The @param nameAdd '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:

MessageFixes
Unknown custom tag <isloyaltybage>: no <ismodule> declares itChange 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> declarationNone. Move the <ismodule> above the first use
<isloyaltybadge> is declared in util/badges.isml, which this template does not includeInclude '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):

FieldDefault
Tag namenewtag, called as <isnewtag>
Templatecomponents/newtag, following the tag name until you edit it. Relative to templates/<locale> of this cartridge, without .isml
Declare inModules 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:

search/productGrid.isml
<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

On this page