Skip to main content

Handlebars Templates for Document Generation

Placeholder syntax for Word and Google Doc templates used with Document Template Tools and use_as_template — variables, conditionals, loops, and Word helpers.

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

{{VariableName}}

Insert a value

#{{{VariableName}}}

Insert raw HTML (unescaped)

{{#if Condition}}...{{/if}}

Render block only when value is truthy

{{#each List}}...{{/each}}

Repeat block for each item in an array

{{this.Property}}

Reference a property within an #each block

{{#docxList items}}...{{/docxList}}

Generate a Word list from an array

{{#docxTable rows}}...{{/docxTable}}

Generate a Word table from an array

{{#docxStyle textColor='RRGGBB'}}...{{/docxStyle}}

Apply dynamic text or background color to a block

{{docxImage src=ImageURL}}

Insert a dynamic image (link via Word bookmark)

{{docxHtml content=HtmlValue}}

Embed HTML as formatted Word content (paragraphs, lists, tables, etc.)

{{docxPageBreak}}

Insert a page break

{{docxRemove v=Condition t="paragraph"}}

Conditionally remove a paragraph, row, or table

Did this answer your question?