Template variables
Template rendering applies to a template’s subject, html, and text, and to any of those
fields you pass directly on the send request.
Syntax
Section titled “Syntax”Variables come from the send request’s data object:
{ "data": { "user": { "name": "Sam" }, "items": ["A", "B"], "pro": true } }| Syntax | Meaning |
|---|---|
{{user.name}} |
Dotted-path lookup into data |
{{#if pro}} … {{else}} … {{/if}} |
Conditional block |
{{#unless pro}} … {{/unless}} |
Inverted conditional |
{{#each items}} {{this}} ({{@index}}) {{/each}} |
Iterate a list; {{this}} is the item, {{@index}} its position |
Unresolved placeholders are left intact rather than erased, and substitution is raw; values are not HTML-escaped, so don’t interpolate untrusted input into HTML.
data vs tags
Section titled “data vs tags”data(object, nested values allowed) is the preferred variable source and enables the block syntax above.tags(flat string map) are metadata first; when a send has nodata, they double as simple{{key}}variables.
When data is present, tags are not used for rendering at all.