Template Syntax
Simple Text Replacement
To insert text in your template, use double curly braces with a tag name:
When you generate a document from the template, this tag will be replaced with the corresponding value from your data. For example:
{
"FirstName": "John"
}
The tag {{ FirstName }}
will be replaced with "John" while preserving any text
formatting (bold, italic, font size, etc.) applied to the tag in the original Word
document.
Loops
To repeat content (like paragraphs, table rows, or list items), use a loop
structure. Loops start with {{>>tag}}
and end with
{{<<}}
, where "tag" refers to the name of your array of data.
Here's an example:
{{ FruitName }}
{{<<}}
Provide an array in your data to populate the loop:
{
"HealthyFood": [
{ "FruitName": "Apple" },
{ "FruitName": "Banana" },
{ "FruitName": "Orange" }
]
}
The resulting document will contain the list of fruits:
Apple
Banana
Orange
Tip: Whitespaces before and after the tag name are ignored.
This means {{tag}}
is the same as {{ tag }}
and
{{>>tag}}
is the same as {{ >> tag }}
.
More Loops
The loop tags can process text blocks, table rows, and list items. The service automatically detects the context and handles the repetition appropriately. So all of the following examples are valid:
Paragraphs
{{>> Pets }}{{ Name }} {{ Type }}
{{<<}}
List Items
- {{>> Pets }}{{ Name }} {{ Type }}{{<<}}
Table Rows
Name | Type |
{{>> Pets }}{{ Name }} | {{ Type }}{{<<}} |
Consider the following data:
{
"Pets": [
{ "Name": "Max", "Type": "Cat" },
{ "Name": "Leo", "Type": "Dog" }
]
}
The resulting document will contain the list of pets in the different formats requested:
Paragraphs
Max Cat
Leo Dog
List Items
- Max Cat
- Leo Dog
Table Rows
Name | Type |
Max | Cat |
Leo | Dog |