The scripting engine checks recognized expressions and <isscript> content and maps its diagnostics back to the template. The useful result depends on the types available to the expression. The ISML server adds its own template checks
Check a known API type
<isscript>
var ProductMgr = require('dw/catalog/ProductMgr');
var product = ProductMgr.getProduct('demo-product');
</isscript>
<isif condition="${product}">
<isprint value="${product.notAMethod()}" />
</isif>Here product comes from a typed SFCC API. Its unknown method can be reported in the editor and Problems panel. By contrast, an arbitrary untyped pdict member may not provide enough information for the same check. See Scripting in ISML
Template checks
While intellij-sfcc.isml.linter is on (default), the ISML server reports these errors as you type:
<isif>,<isloop>,<isscript>,<iscomment>and<isdecorate>left open, and closing tags that close nothing<iselseif>and<iselse>outside<isif>or after<iselse>- Missing required attributes, such as
conditionon<isif>ortemplateon<isinclude> - A bare # in template text
The structural errors have the source isml in the Problems panel. In the messages below, tag stands for the tag that is reported and other for the outer tag:
| Message | Reported when |
|---|---|
Closing </tag> has no matching <tag> | A </isif>, </isloop>, </isscript>, </iscomment> or </isdecorate> closes nothing |
<tag> is not closed before </other> | A tag opened inside other is still open at </other>, as in <isif><isloop></isif> |
<tag> is not closed | An <isif>, <isloop>, <isscript>, <iscomment> or <isdecorate> is still open at the end of the template |
<tag> must be inside <isif> | <iselse> or <iselseif> outside an <isif> |
<tag> cannot follow <iselse> | A second <iselse>, or an <iselseif>, after the <iselse> of the same <isif> |
<tag> requires the "attribute" attribute | A required attribute is missing, see the next table |
| Tag | Required attributes, as the message names them |
|---|---|
<isif>, <iselseif> | "condition" |
<isloop> | "items" or "iterator" or "begin" |
<isinclude> | "template" or "url" |
<isdecorate> | "template" |
<ismodule> | "template" and "name", one message each |
<isset> | "name" and "value", one message each |
<isprint> | "value" |
Unknown tags and attributes and HTML problems are not reported, and rendering on a sandbox is still the check of runtime behavior. The built-in XML validator handles supported SFCC XML schemas, not templates
Bare # in template text
A # in what the template prints is an error: HTML text and attribute values, <script> and <style> bodies, HTML comments, and the whole text of a JavaScript or JSON template (<iscontent type="application/json">). 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 #
# is an error. The quick fixes write ${'#'} for this one or every one in the file, with ${"#"} inside single quotes. Format Document writes the same escapes and leaves the # of ISML attributes such as formatter alone- Quick Fix (
Cmd+.,Ctrl+.) offers Replace with ${'#'}, and Escape every # in the file when the file has more than one bare#. Inside single quotes, in an attribute value or a script string, the fix writes${"#"}, so the quotes still pair - Fix All and
"source.fixAll"ineditor.codeActionsOnSaveescape every bare#. Format Document and Organize Imports do too whileintellij-sfcc.isml.formatter.escapeHashis on, see Formatting - Not reported:
#inside${},<isscript>and<iscomment>, in ISML attributes such asformatter="#,##0.00", character references such as☰, and the folding markers<!-- #region -->and<!-- #endregion -->
Follow a problem to its source
Use Go to Definition or hover to inspect the type behind a diagnostic. Check that imported scripts and metadata are present locally, and allow indexing to finish after structural changes
For the shared checker behavior, legacy filtering, and code-action limitations, see Scripting diagnostics. For indentation and layout, see Formatting