ISML
Velocity
DID THIS ARTICLE SOLVE YOUR ISSUE?
Let us know so we can improve!
Let us know so we can improve!
This class renders an Apache Velocity template. For Velocity template syntax, see Velocity 1.7.
The render() methods identify the template to render from:
Note: Files included from an ISML template (either via #parse or #include) are always resolved
in the Dynamic location, and it is not possible to provide an absolute path.
On the target side of rendering, by default the render() methods write to the current response writer. When needed,
a dw.io.Writer can be supplied as a target.
Parameters for rendering can be passed as a single object holding the parameters as properties.
To create a URL, pass the URLUtils class.
To access localized strings, pass the Resource class:
1var urlUtil = require('dw/web/URLUtils');
2velocity.render("$url.abs('Foo-Bar','cgid',$res.msg('key')", {'url' : urlUtil, 'res' : dw.web.Resource});The complete set of VelocityTools are provided to the template. You can use the tools to escape dynamic data, format text, and for other common tasks.
Template files are cached for different amounts of time, depending on the instance type.
This class does not have a constructor, so you cannot create it directly.
| Method | Description |
|---|---|
| static remoteInclude(String, String…) | Includes the rendered content of the specified action URL, which usually is a pipeline or controller. |
| static render(String, Object) | Renders an inline template to the response writer. |
| static render(String, Object, Writer) | Renders an inline template to the provided writer. |
| static renderTemplate(File, Object) | Renders a template file to the response writer. |
| static renderTemplate(File, Object, Writer) | Renders a template file to the provided writer. |
| static renderTemplate(String, Object) | Renders a template file to the response writer. |
| static renderTemplate(String, Object, Writer) | Renders a template file to the provided writer. |
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
Includes the rendered content of the specified action URL, which usually is a pipeline or controller. Must only be used inside a Velocity
template, such as $velocity.remoteInclude('Product-Show','sku','42')
Parameters:
Returns:
Renders an inline template to the response writer.
Parameters:
Renders an inline template to the provided writer.
Parameters:
Renders a template file to the response writer.
Parameters:
Renders a template file to the provided writer.
Parameters:
Renders a template file to the response writer.
Parameters:
1https://mydomain.com/on/demandware.servlet/webdav/Sites/Dynamic/SiteGenesis/myfile.vmrender the file in this way:
1velocity.renderTemplate("myfile.vm", null);1- args - the argument objectRenders a template file to the provided writer.
Parameters:
1https://mydomain.com/on/demandware.servlet/webdav/Sites/Dynamic/SiteGenesis/mydir/myfile.vmrender the file in this way:
1velocity.renderTemplate("mydir/myfile.vm", null, result);1- args - the argument object to pass to the template
2- writer - the target writer