ISML inspections run as you type, most with a quick fix. They're in Settings › Editor › Inspections › SFCC › ISML. Turning off the whole ISML group matches the VS Code intellij-sfcc.isml.linter setting
Checks that read only the template and the tag catalog are free and work while the IDE indexes. Checks that read other files (templates, controllers, resource bundles) need a license and wait until indexing ends
Syntax
All free:
| Inspection | Level | Message | Fix |
|---|---|---|---|
| ISML tag outside its parent tag | Error | <isnext> outside <isloop>, A second <iselse> in one <isif> | Remove <isnext>, Remove <iselse> |
| Branch after iselse | Error | <iselseif> after <iselse> | Move before <iselse>, with its body |
| Unescaped # in template text | Error | Unescaped # in template text, see Bare # | Replace with ${'#'}, Escape every # in the file |
| ISML closing tag that closes nothing | Warning | </isset>: <isset> has no closing tag | Remove </isset> |
| Self-closed paired ISML tag | Warning | <isif> must not be self-closed | Remove '/' when an end tag follows, otherwise Expand to a start and an end tag |
| Redundant iselse or iselseif closing tag | Weak warning | Redundant </iselse> | Remove </iselse> |
| ISML tag name not in lower case | Weak warning | ISML tag names are lower case | Convert the tag name to lower case |
Bare # in template text
A # in what the template prints is an error: HTML text and attribute values, <script> and <style> bodies, HTML comments. ISML can read a # outside ${} as expression syntax, so the text around it may not print as written. Print it with ${'#'}, an expression whose value is #
- Inside single quotes, in an attribute value or a script string, the fix writes
${"#"}, so the quotes still pair - Not reported:
#inside${},<isscript>and<iscomment>, in ISML attributes such asformatter="#,##0.00", character references such as☰, and the folding markers<!-- #region -->and<!-- #endregion --> - Code Cleanup applies the fix, and Reformat Code and Optimize Imports write the escapes, see Formatting
Attributes
Free, except the custom tag parts, see Custom Tags
| Inspection | Message | Fixes |
|---|---|---|
| Unknown ISML attribute | Unknown attribute 'tempate' of <isinclude> | Change to 'template' for a close name, Remove 'tempate' |
| Missing required ISML attribute | <isset> needs 'value', <isinclude> needs 'template' or 'url' | Add 'value', or one Add fix for each choice |
| Conflicting ISML attributes | 'template' cannot be combined with 'url' | Remove one of them |
| Duplicate ISML attribute | A second copy of an attribute | Remove the copy |
| Invalid ISML attribute value | 'scope' takes literal text, not an expression, 'items' takes an expression: 'pdict.products' is literal text, 'sesion' is not a value of 'scope': page, request, session, 'hour' takes a whole number | Remove ${}, Wrap in ${}, Change to 'session' for a close value |
| Deprecated ISML tag, attribute or value | 'iterator' is deprecated, use 'items', shown struck through | Change to 'items' when the catalog names a replacement |
| iscontent not first or repeated | More than one <iscontent>, <iscontent> after <div>, which can write output | Remove the duplicate <iscontent>, Move to the top of the file |
| iscontent type does not match the data | A JSON or XML body under a text/html <iscontent>, as a weak warning | Change to the type that fits |
| ISML attribute set to its default | Off by default. A weak warning on scope="session" and other defaults | Remove the attribute |
Best practice
| Inspection | Message | Fixes |
|---|---|---|
| isset without scope | <isset> without scope keeps total for the whole session | Add scope="page", Add scope="request", Add scope="session" |
| iscache settings | <iscache> without type, Another <iscache> in this template has other settings, <isredirect> after <iscache>: the redirect is cached too | Add type="relative", Remove this <iscache> |
| Template includes itself | This template includes itself through product/tile → product/productTile. Needs a license | Open the template that closes the loop |
Templates, routes and resources
These need a license:
| Inspection | Level | Message | Fixes |
|---|---|---|---|
| Unresolved ISML template | Error | Cannot resolve template 'product/loyaltyBanner' | Create template |
| Error | Cannot resolve template 'product/Tile': the file is 'product/tile', and template paths are case-sensitive | Change to 'product/tile', in your path style | |
| Error | Template 'account/rewards' is not on the cartridge path of site RefArch; it exists in plugin_loyalty | None. Add the cartridge to the site's cartridge path | |
| Weak warning | No template matches 'product/components/*', where * is an expression in the path | None | |
| Unknown ISML custom tag | Warning | Unknown custom tag <isloyaltybage>: no <ismodule> declares it | See Custom Tags |
| Unresolved route in an ISML template | Warning | Cannot resolve route 'Loyalty-Shwo'. Only literal Controller-Action names are checked | Change to 'Loyalty-Show' for a close route |
| Unresolved Resource bundle or key in an ISML template | Warning | Cannot resolve bundle 'acount', Cannot resolve key 'heading.loyalty' in bundle 'account'. A require key that is itself a script path isn't reported, as B2C returns the key | Create key 'heading.loyalty' in bundle 'account', Use bundle 'common', which has the key |
Create template asks for the cartridge (this one first, then the cartridge path) and writes the ISML Template text of Settings › Editor › File and Code Templates under its templates/default/
Output encoding
B2C HTML-encodes ${} and <isprint> by default, which is wrong in a <script> block or CSS. These checks report an encoding that doesn't fit where the value lands:
| Inspection | Message | Fixes |
|---|---|---|
| isprint with encoding off | encoding="off" prints the value as it is into a string in a <script> block; expected "jsblock" | Change to encoding="jsblock" |
| isprint encoding does not fit the output position | encoding="htmlcontent" does not fit a string in a <script> block; expected "jsblock", No encoding protects a value in <script> code outside a string literal; print it inside a string literal | Change to encoding="jsblock" |
| HTML-encoded output in script or CSS | ${} uses HTML encoding, which does not protect a string in an event handler attribute; expected "jsattribute", also for <isprint> without encoding in a <script> block. A bare ${} in a <script> block gets the blue note instead | Wrap in <isprint encoding="jsattribute">, Add encoding="jsblock" |
| Server-side ${} in a JavaScript template literal | B2C evaluates ${name...} on the server, where 'name' is not defined; the template literal never sees it. Needs a license | Replace with ${'$'}{name} for the browser, Convert the template literal to string concatenation |
Shared options: Expressions treated as safe are never reported (* matches any text), and Ignore string literals (on) skips ${'text'}. isprint with encoding off skips HTML and XML text unless Report HTML and XML text is on. HTML-encoded output in script or CSS reports CSS values only with Report values in CSS
Server-side expressions in scripts
B2C evaluates every ${} of a template on the server, also inside a <script> block and between the backticks of a JavaScript template literal. The plugin reads each ${} in a <script> block as an ISML expression and marks it with a blue wave, except the escapes ${'$'} and ${'#'}, which print one character. It's a note, not a problem: no icon and no count in the problems widget. Hover it to see what the printed value turns into there
${} in a <script> block runs on the server, also between backticks. The blue wave is a note, not a problem: its tooltip says what the printed value turns into there, and in a string the fix wraps it in <isprint encoding="jsblock">- In a string, the value arrives HTML-encoded:
&becomes&, and a backslash or a line break still ends the string. Wrap in <isprint encoding="jsblock"> escapes it for JavaScript,jsonvaluein a JSON block - In code, numbers and booleans print as they are, but quotes become
". No encoding makes a value safe as code, so print strings inside quotes - Between backticks, the
${}still runs on the server. For a placeholder the browser fills, write${'$'}{name}: B2C prints${'$'}as$and leaves{name}as text, so the browser gets${name}. Replace with ${'$'}{name} for the browser makes the change. A placeholder whose name the template doesn't define is a warning, with that fix first - To print
${name}as text anywhere in the block, for a client-side template for example, Replace with ${'$'}{name} makes the same change. Inside a single-quoted string it writes${"$"}{name}, as the bare#fix does. Fix All leaves it out, since it would drop every server value
The note is Server-side ${} in a script block in the Security group. Its color is Settings › Editor › Color Scheme › ISML › Expressions › Server-side ${ } in <script>. To review these values as problems, raise the inspection's severity
Template variables
These wait until indexing ends:
| Inspection | Message | Fixes |
|---|---|---|
| Unknown pdict member | No render call of this template sets 'pdict.nextReward'. Needs a license | Change to a close member name, Declare 'pdict.nextReward' with @pdict, Add 'nextReward' to the render model in Loyalty.js |
| Template variable used before its declaration | 'total' is used before the <isset> that declares it | Move <isset> above the first use |
| Template variable used after isremove | 'total' is used after <isremove> removed it | Remove <isremove> |
| Unused template variable | Template variable 'total' is never read, Loop variable 'item' is never read, Loop status 'loopState' is never read. Only page and request variables are reported | Remove <isset>, Remove status |
| Attribute expression type mismatch | ... is always true as a condition: test its size, or use empty(), <isloop> cannot iterate over ..., Expected a number, found ..., Expected a URL or a string, found ..., Expected a dw.web.FormField, found ..., as weak warnings | None |
| Script syntax the compatibility mode does not support | Compatibility mode 21.2 does not support template literals (22.7 or later), No B2C compatibility mode supports optional chaining. Error, free | None |
Unused template variable counts reads in the other templates that can see the variable, see Across templates. A variable an included template sets isn't reported when the template that includes it reads it, and a loop variable isn't reported when a template included in the loop reads it. A request variable is still reported when only a template that never includes this one reads it
'let' or 'const' in server code runs in <isscript> too, with Replace 'let' with 'var' and Replace 'const' with 'var', see let and const
Add to the render model adds the member to the render call's object literal, keeping its layout, and leaves the caret after nextReward: in the controller. It's offered for up to three render calls that pass an object literal. Members are checked only in templates whose render calls are all known, see Scripting in ISML
Suppressing a problem
Alt+Enter on a problem, then the arrow next to a fix, offers Suppress for tag and Suppress for file. Both write an <iscomment>, which B2C never sends to the browser:
<iscomment>noinspection IsmlIssetWithoutScope</iscomment>
<isset name="basket" value="${pdict.basket}" />Before a tag it covers the tag and its body, as the first item of the file the whole file, including problems inside ${} and <isscript>
HTML warnings the plugin hides
- Closing tag matches nothing and Start tag has wrong closing tag when the tags pair across
<isif>branches, such as a<div>opened in both branches and closed once after</isif>. A stray end tag is still reported - HTML parse errors next to ISML tags and
${} - HTML and XML inspections that would read an ISML value, such as Unknown target on
href="${URLUtils.url('Cart-Show')}"