Template Syntax
Templates use Handlebars syntax: text with {{ }} placeholders that a workflow fills at run time. This page lists the forms and helpers you can use, how each template type escapes values, and what Studio checks before it lets you save.
In the template editor, select Syntax to see the forms and helpers without leaving the page.
Placeholders and blocks
| Form | What it does |
|---|---|
{{field}} | Inserts a value. |
{{a.b}} | Inserts a nested value. |
{{#each items}}...{{/each}} | Repeats the block for each item in a list. |
{{#if x}}...{{else}}...{{/if}} | Chooses between two blocks. |
{{! note }} | A comment. It is not written to the result. |
The engine also supports unless, with, lookup, else if chains, block parameters, @index, @key, @first, @last, @root, ../, this, sub-expressions, and ~ whitespace control. External partials, written as {{> name}}, are not supported. Define a partial inline with {{#*inline "name"}}, or write the content in place.
An unknown helper stops the activity when it runs. In the editor an unknown helper shows as a warning, so check each helper name against the next table.
Helpers
| Helper | What it does |
|---|---|
eq, ne | True when two values are strictly equal, or when they differ. |
lt, gt, lte, gte | Compare numbers. |
and, or | True when every, or any, argument is truthy. |
not | Negates a value. |
default value fallback | The value, or the fallback when it is empty. |
uppercase, lowercase | Change the case of text. |
formatDate value "pattern" | Formats an ISO date using YYYY MM DD HH mm ss. A value that is not an ISO date is returned unchanged, and a missing time becomes 00. |
formatNumber value places | Formats a number with a fixed number of decimals. The default is 2. |
join list "separator" | Joins a list with a separator. The default separator is a comma and a space. |
json value | Writes a value as JSON. In an HTTP (HTML) template it is made safe for markup. |
formatDate reads the date and time as written and ignores time zones. Comparison helpers such as gt read their arguments as numbers.
Escaping by type
| Type | {{x}} | {{{x}}} |
|---|---|---|
| JSON | Escaped as the inside of a JSON string. | Written as is. |
| XML | Escaped for markup. | Written as is. |
| HTTP (HTML) | Escaped for markup. | Written as is. |
| Text | Not escaped. | Not escaped. |
Use {{{x}}} only for values you trust. In an HTML template it can inject markup if the value comes from a caller.
For JSON, put text values in quotes and numbers and booleans outside quotes. Use {{json value}} for an object or a list:
Studio fills every field with sample data when it checks JSON, so a missing value at run time is not caught in the editor. Write {"a": {{x}} } with a space before the closing braces, because }}} always closes a triple-brace placeholder.
What Studio checks
Studio checks the text 400 milliseconds after you stop typing, and immediately when you change the type.
| Type | Blocks saving (error) | Does not block (warning) |
|---|---|---|
| All | Handlebars syntax errors. | Text over 200,000 characters skips the checks, with a warning. |
| JSON | The text does not parse as JSON, or does not produce valid JSON when rendered with sample data. | |
| XML | The XML is not well formed, or has more than one root element. | |
| HTTP (HTML) | The security rules in the next section. | A tag that is never closed or has no matching opening tag, and raw {{{ }}} output. |
| Text | None. |
The status line under the editor reads No problems found, or a count of problems and warnings with the first one and its line.
Security rules for HTTP (HTML)
An HTTP (HTML) template cannot contain:
- an executable
<script>. Usetype="application/json"ortype="application/ld+json"for data. The typesimportmap+json,text/template,text/plain,text/html, andtext/x-handlebars-templateare also allowed; <iframe>,<frame>,<frameset>,<object>,<embed>, or<applet>;<base>;<meta http-equiv="refresh">;- inline event handlers such as
onclick; - a
srcdocattribute; - a
javascript:,vbscript:, ordata:text/htmladdress; - a style that runs script.
Size
| Item | Limit |
|---|---|
| Template name | 256 characters. |
| Description | 1,000 characters. |
| Template text | 512,000 characters. Studio skips syntax checks above 200,000. |