Skip to Content

Inspections

ISML inspections in JetBrains IDEs for syntax, attributes, templates, routes, resources, encoding and variables, with quick fixes and suppression comments

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

A template path that resolves to no file is an error. Create template asks for the cartridge, this one first and then the cartridge path, and writes the file from the ISML Template file template

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:

InspectionLevelMessageFix
ISML tag outside its parent tagError<isnext> outside <isloop>, A second <iselse> in one <isif>Remove <isnext>, Remove <iselse>
Branch after iselseError<iselseif> after <iselse>Move before <iselse>, with its body
Unescaped # in template textErrorUnescaped # in template text, see Bare #Replace with ${'#'}, Escape every # in the file
ISML closing tag that closes nothingWarning</isset>: <isset> has no closing tagRemove </isset>
Self-closed paired ISML tagWarning<isif> must not be self-closedRemove '/' when an end tag follows, otherwise Expand to a start and an end tag
Redundant iselse or iselseif closing tagWeak warningRedundant </iselse>Remove </iselse>
ISML tag name not in lower caseWeak warningISML tag names are lower caseConvert 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 as formatter="#,##0.00", character references such as &#9776;, 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

InspectionMessageFixes
Unknown ISML attributeUnknown 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 attributeA second copy of an attributeRemove 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 numberRemove ${}, Wrap in ${}, Change to 'session' for a close value
Deprecated ISML tag, attribute or value'iterator' is deprecated, use 'items', shown struck throughChange to 'items' when the catalog names a replacement
iscontent not first or repeatedMore than one <iscontent>, <iscontent> after <div>, which can write outputRemove the duplicate <iscontent>, Move to the top of the file
iscontent type does not match the dataA JSON or XML body under a text/html <iscontent>, as a weak warningChange to the type that fits
ISML attribute set to its defaultOff by default. A weak warning on scope="session" and other defaultsRemove the attribute

Best practice

InspectionMessageFixes
isset without scope<isset> without scope keeps total for the whole sessionAdd 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 tooAdd type="relative", Remove this <iscache>
Template includes itselfThis template includes itself through product/tile → product/productTile. Needs a licenseOpen the template that closes the loop

Templates, routes and resources

These need a license:

InspectionLevelMessageFixes
Unresolved ISML templateErrorCannot resolve template 'product/loyaltyBanner'Create template
ErrorCannot resolve template 'product/Tile': the file is 'product/tile', and template paths are case-sensitiveChange to 'product/tile', in your path style
ErrorTemplate 'account/rewards' is not on the cartridge path of site RefArch; it exists in plugin_loyaltyNone. Add the cartridge to the site's cartridge path
Weak warningNo template matches 'product/components/*', where * is an expression in the pathNone
Unknown ISML custom tagWarningUnknown custom tag <isloyaltybage>: no <ismodule> declares itSee Custom Tags
Unresolved route in an ISML templateWarningCannot resolve route 'Loyalty-Shwo'. Only literal Controller-Action names are checkedChange to 'Loyalty-Show' for a close route
Unresolved Resource bundle or key in an ISML templateWarningCannot 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 keyCreate 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:

InspectionMessageFixes
isprint with encoding offencoding="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 positionencoding="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 literalChange 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 insteadWrap in <isprint encoding="jsattribute">, Add encoding="jsblock"
Server-side ${} in a JavaScript template literalB2C evaluates ${name...} on the server, where 'name' is not defined; the template literal never sees it. Needs a licenseReplace 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

Every ${} 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 &amp;, and a backslash or a line break still ends the string. Wrap in <isprint encoding="jsblock"> escapes it for JavaScript, jsonvalue in a JSON block
  • In code, numbers and booleans print as they are, but quotes become &quot;. 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:

InspectionMessageFixes
Unknown pdict memberNo render call of this template sets 'pdict.nextReward'. Needs a licenseChange 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 itMove <isset> above the first use
Template variable used after isremove'total' is used after <isremove> removed itRemove <isremove>
Unused template variableTemplate variable 'total' is never read, Loop variable 'item' is never read, Loop status 'loopState' is never read. Only page and request variables are reportedRemove <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 warningsNone
Script syntax the compatibility mode does not supportCompatibility mode 21.2 does not support template literals (22.7 or later), No B2C compatibility mode supports optional chaining. Error, freeNone

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')}"

On this page