Class ISML

This class provides support for rendering ISML templates. For more details about the ISML syntax, refer to the Commerce Cloud Digital developer documentation. Templates are stored as *.isml files. They are located in a locale-specific folder under the ‘/cartridge/templates’ folder, with ‘/cartridge/template/default’ being the default locale. The template name arguments of the various render methods represent the template path (without file ending) within this folder structure.

Example for rendering a template with arguments from JavaScript code:

1let isml = require('dw/template/ISML');
2isml.renderTemplate('helloworld', {
3    Message: 'Hello, World!'
4});

Example code for accessing the template arguments in the ‘helloworld.isml’ template from the above code snippet:

1The message is: <isprint value="${pdict.Message}" />

Constructor Summary 

This class does not have a constructor, so you cannot create it directly.

Method Summary 

MethodDescription
static renderTemplate(String)Renders an ISML template and writes the output to the current response.
static renderTemplate(String, Object)Renders an ISML template and writes the output to the current response.
static renderTemplate(String)Renders an ISML template and writes the output to the current response.
static renderTemplate(String, Object)Renders an ISML template and writes the output to the current response.

Methods inherited from class Object 

assign, create, create, defineProperties, defineProperty, entries, freeze, fromEntries, getOwnPropertyDescriptor, getOwnPropertyNames, getOwnPropertySymbols, getPrototypeOf, hasOwnProperty, is, isExtensible, isFrozen, isPrototypeOf, isSealed, keys, preventExtensions, propertyIsEnumerable, seal, setPrototypeOf, toLocaleString, toString, valueOf, values

Method Details 

renderTemplate(String) - Variant 1 

static renderTemplate(template: String): void

Renders an ISML template and writes the output to the current response. The template may contain ISML tags which control the character encoding, content type, caching behavior and so on of the response (see ISML documentation).

Parameters:

  • template - the template path

API Version:

No longer available as of version 17.7. Puts template arguments into the global pipeline dictionary.

Note


renderTemplate(String, Object) - Variant 1 

static renderTemplate(template: String, templateArgs: Object): void

Renders an ISML template and writes the output to the current response. The template may contain ISML tags which control the character encoding, content type, caching behavior and so on of the response (see ISML documentation). This method takes an additional JavaScript object as argument. Its properties are accessible for script expressions in the template under the "pdict.*" variable.

Parameters:

  • template - the template path
  • templateArgs - the template arguments object

API Version:

No longer available as of version 17.7. Puts template arguments into the global pipeline dictionary.

Note


renderTemplate(String) - Variant 2 

static renderTemplate(template: String): void

Renders an ISML template and writes the output to the current response. The template may contain ISML tags which control the character encoding, content type, caching behavior and so on of the response (see ISML documentation).

Parameters:

  • template - the template path

API Version:

Available from version 17.7. Keeps template arguments in a local pipeline dictionary scope. This avoids side-effects on other templates.

Note


renderTemplate(String, Object) - Variant 2 

static renderTemplate(template: String, templateArgs: Object): void

Renders an ISML template and writes the output to the current response. The template may contain ISML tags which control the character encoding, content type, caching behavior and so on of the response (see ISML documentation). This method takes an additional JavaScript object as argument. Its properties are accessible for script expressions in the template under the "pdict.*" variable.

Parameters:

  • template - the template path
  • templateArgs - the template arguments object

API Version:

Available from version 17.7. Keeps template arguments in a local pipeline dictionary scope. This avoids side-effects on other templates.

Note


DID THIS ARTICLE SOLVE YOUR ISSUE?
Let us know so we can improve!