HTML & JSON output
HTML-safe block helpers
HTML editors such as CKEditor enforce valid HTML structure. When you place Handlebars block helpers (e.g. {{#each}}) as free text inside a <table>, the editor moves them outside the table because they are not valid table children. The result is a broken template.
To work around this, the templating engine supports two custom HTML data attributes that let you embed Handlebars block helpers directly on an element:
| attribute | description |
|---|---|
data-template-start | The opening Handlebars expression, injected as text immediately before the element at processing time |
data-template-end | The closing Handlebars expression, injected as text immediately after the element at processing time |
Because these are standard HTML attributes, the editor treats the element as valid HTML and leaves it alone. The backend preprocessor (AngleSharp) strips the attributes and inserts the expression text before template compilation — producing output identical to the free-text approach.
Old approach — broken in HTML editors:
{{#sortedArray __AdditionalData.statementOfFacts 'date'}}{{#each this}}
<tr>
<td>{{dateFormat date 'dddd dd-MM' 'en-US'}}</td>
<td>{{__DataFieldFormatting.event.__DisplayName}}</td>
<td>{{remarks}}</td>
</tr>
{{/each}}{{/sortedArray}}
New approach — HTML-safe:
<tr
data-template-start="{{#sortedArray __AdditionalData.statementOfFacts 'date'}}{{#each this}}"
data-template-end="{{/each}}{{/sortedArray}}"
>
<td>{{dateFormat date 'dddd dd-MM' 'en-US'}}</td>
<td>{{__DataFieldFormatting.event.__DisplayName}}</td>
<td>{{remarks}}</td>
</tr>
When to use this
- Both
data-template-startanddata-template-endmust appear on the same element. An element with only one of the two attributes is silently ignored. - The attribute values are inserted verbatim — make sure opening and closing expressions are balanced.
- Works on any host element (
<tr>,<div>,<li>, etc.), not just table rows.
Migration note: Existing templates using free-text Handlebars around HTML elements continue to work — nothing is broken by default. Migration is only necessary when you need to open and edit such a template in the HTML editor (CKEditor). Opening a legacy template in the editor will reposition the free-text syntax and break the preview. Rewrite the affected blocks to use data-template-start / data-template-end at that point.
JSON output (raw and encoded)
The templating engine can output the current data context as JSON. There are two variants — note the difference in curly-bracket count.
Raw JSON — outputs unescaped JSON (use in a JSON template or where the consumer parses it directly):
{{{ json this }}}
Encoded JSON — outputs HTML-encoded JSON (safe for embedding inside HTML or XML):
{{ this | json }}
Use the encoded form when the JSON will appear inside an HTML attribute or element value. Use the raw form when the full JSON object needs to be passed through as-is.