Advanced expansion
Expansion expressions can not contain logic (if/else/etc), but it is possible to iterate lists and include/exclude content based on specific conditions using sections.
When advanced expansion (mustache syntax) is used, bracket notation (${list[0]}, ${obj['key']}) and escaped dots (${path\.key}) are not supported. Use dot notation for list indices (${list.0}) and avoid keys containing literal dots.
Sections
Sections enable conditional rendering and iteration using mustache syntax. A section starts with {{#name}} and ends with {{/name}}.
A section MUST:
start with tag
{{#<name>}}end with tag
{{/<name>}}reference a property by (path and) name
A section MAY:
contain expansion expressions (
${...})static text
Example of section referencing property 'path.name'
{{#path.name}}
// Section content
{{/path.name}}Rendering behaviour
Sections behave different depending on the type of the referenced property:
If the property doesn't exist, has no value or is false nothing will be rendered
If the property is a list (multi-value) the content of the section will be rendered for each element in the list
Otherwise section content will be rendered once
Within a section, ${.} references the current value or list element and is implicit when referencing properties on the current element (${name} expands to property name on the current element).
Standard property paths are also available and search the current context first, then top-level scopes.
List iteration
Object properties within a section
Nested path
Inverted sections
An inverted section ({{^name}}) renders when the value is absent, false, or an empty list — the opposite of a regular section.
Special variables
Inside a list section, mustache provides some built-in variables:
{{@last}}
True for the last element in the list
{{@first}}
True for the first element in the list
{{@index}}
Zero-based index of the current element
These are typically used with inverted sections to control separators:
Unescaped output
By default, {{value}} escapes HTML special characters. Use triple braces to output raw values:
${...} expressions are always unescaped.
Mixing syntax
Both syntaxes can be used in the same value. As soon as mustache syntax ({{) is detected, the entire value is processed as a mustache template — including all ${...} expressions.
Note: bracket notation (${list[0]}, ${obj['key']}) is not supported in mustache context. Use dot notation instead:
bracket notation (${list[0]}, ${obj['key']}) is not supported in mustache context. Use dot notation instead:
Examples
Render a simple list
Given the following list of strings:
this expression:
will render (note the trailing comma):
To remove the trailing comma, we can embed an inverted section using the @last property on the current list item (only rendered when element is not "last" in list):
This will render:
Render an object
Given the following object:
this expression:
will render:
Last updated