Handlebars Templates for Document Generation
A document template is a Word document or Google Doc that contains placeholders written as double curly braces around a variable name, like {{VariableName}}. When a workflow runs, the platform substitutes those placeholders with real data to produce a finished document.
This article is the syntax reference for those placeholders. For when to use a Document Template Tool versus use_as_template, and how to set each up, see Generate documents from templates.
Template Syntax
Variable Substitution
A placeholder is written as {{VariableName}} and placed anywhere in the document body, table cells, headings, or footers. When the workflow runs, the platform replaces each placeholder with the matching data value.
Employment Verification Letter
Employee: {{EmployeeName}}
Job Title: {{JobTitle}}
Start Date: {{StartDate}}
Contract: {{ContractType}}
Location: {{WorkLocation}}
{{Purpose}}
Conditional Blocks
{{#if VariableName}} renders a block only when the value is truthy.
{{#if SalaryIncluded}}
Compensation: {{CompensationBase}}
{{/if}}
If SalaryIncluded has no value (is empty or false), the block is omitted.
Loops
{{#each List}} repeats a block once for each item in an array.
{{#each OrderItems}}
- {{this.Description}}: {{this.Quantity}} units
{{/each}}
For Word tables and lists, prefer the Word-oriented helpers in the syntax reference below ({{#docxTable}}, {{#docxList}}).
Unescaped HTML
Triple braces #{{{VariableName}}} insert the value as raw HTML rather than escaped text. This is appropriate when the value contains HTML markup.
Troubleshooting
Error: “use_as_template tool is not found”
This error can appear when the template itself contains a syntax error, not just when the tool is misconfigured. The most common cause is an unclosed block helper.
If you see this error, check the template file first for Handlebars syntax errors:
Verify every
{{#docxTable}}has a matching{{/docxTable}}at the end of the last row. The same applies to{{#docxList}},{{#if}},{{#each}}, and{{#docxStyle}}— every opening tag needs a closing tag.Make sure that opening braces all have the equivalent closing braces.
A missing closing tag is easy to miss.
Syntax Reference
This is a partial list of commonly used helpers.
Syntax | Purpose |
| Insert a value |
| Insert raw HTML (unescaped) |
| Render block only when value is truthy |
| Repeat block for each item in an array |
| Reference a property within an |
| Generate a Word list from an array |
| Generate a Word table from an array |
| Apply dynamic text or background color to a block |
| Insert a dynamic image (link via Word bookmark) |
| Embed HTML as formatted Word content (paragraphs, lists, tables, etc.) |
| Insert a page break |
| Conditionally remove a paragraph, row, or table |
