Advanced expansion
Advanced expansion reference and configuration shared across Fortified ID products.
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.
Sections
Section titled “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
Rendering behaviour
Section titled “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
Section titled “List iteration”{{#items}}${.}{{/items}}Object properties within a section
Section titled “Object properties within a section”{{#user}}${name} (${id}){{/user}}Nested path
Section titled “Nested path”{{#response.user}}${name}{{/response.user}}Inverted sections
Section titled “Inverted sections”An inverted section ({{^name}}) renders when the value is absent, false, or an empty list — the opposite of a regular section.
{{^errors}}No errors.{{/errors}}{{^items}}The list is empty.{{/items}}Special variables
Section titled “Special variables”Inside a list section, mustache provides some built-in variables:
| Variable | Meaning |
|---|---|
{{@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:
{{#items}}${.}{{^@last}}, {{/@last}}{{/items}} → a, b, cUnescaped output
Section titled “Unescaped output”By default, {{value}} escapes HTML special characters. Use triple braces to output raw values:
{{{value}}}Mixing syntax
Section titled “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.
User: ${user.name} — active: {{user.active}}Note: bracket notation (${list[0]}, ${obj['key']}) is not supported in mustache context. Use dot notation instead:
Examples
Section titled “Examples”Render a simple list
Section titled “Render a simple list”Given the following list of strings:
"list" : ["elem01", "elem02", "elem03"]this expression:
{{#list}}${.},{{/list}}will render (note the trailing comma):
elem01,elem02,elem03,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):
{{#list}}${.}{{^@last}}, {{/@last}}{{/list}}This will render:
elem01, elem02, elem03Render an object
Section titled “Render an object”Given the following object:
"user": { "id": "user00", "name": "First user"}this expression:
{{#user}}User: ${name} (id: ${id}){{/user}}will render:
User: First user (id: user00)