Skip to main content

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​

FormWhat 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​

HelperWhat it does
eq, neTrue when two values are strictly equal, or when they differ.
lt, gt, lte, gteCompare numbers.
and, orTrue when every, or any, argument is truthy.
notNegates a value.
default value fallbackThe value, or the fallback when it is empty.
uppercase, lowercaseChange 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 placesFormats 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 valueWrites 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}}}
JSONEscaped as the inside of a JSON string.Written as is.
XMLEscaped for markup.Written as is.
HTTP (HTML)Escaped for markup.Written as is.
TextNot 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:

{
"name": "{{customer.name}}",
"points": {{customer.points}},
"orders": {{json orders}}
}

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.

TypeBlocks saving (error)Does not block (warning)
AllHandlebars syntax errors.Text over 200,000 characters skips the checks, with a warning.
JSONThe text does not parse as JSON, or does not produce valid JSON when rendered with sample data.
XMLThe 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.
TextNone.

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>. Use type="application/json" or type="application/ld+json" for data. The types importmap+json, text/template, text/plain, text/html, and text/x-handlebars-template are also allowed;
  • <iframe>, <frame>, <frameset>, <object>, <embed>, or <applet>;
  • <base>;
  • <meta http-equiv="refresh">;
  • inline event handlers such as onclick;
  • a srcdoc attribute;
  • a javascript:, vbscript:, or data:text/html address;
  • a style that runs script.

Size​

ItemLimit
Template name256 characters.
Description1,000 characters.
Template text512,000 characters. Studio skips syntax checks above 200,000.