This article introduces the modern DOCX templating engine. We’ll cover the basics, including how to generate dynamic text, bullet lists, and tables in your templates.
Note
Modern engine is currently only available in Processes. To enable it, navigate to template settings and select ‘Modern’ under the Template engine setting.
Let’s take a look at an easy example of how to add dynamic text into your template.
Suppose we have the following JSON, and we want to incorporate the company name into our template:
{
"name": "Oliver Smith"
}
To insert the dynamic company name into your template, simply wrap the key (name in this case) in curly braces like so: {{name}}
. This turns it into a token that will be replaced with the actual value.
Now, let’s insert this token into our template and start the generation process using the JSON mentioned.
Template:
Result:
There’s no need to declare any loops; the templating engine is smart enough to recognize the structure of the source object applied to your document. This means that if you reference a property of an object within a collection, it will automatically understand that it needs to iterate through the items.
For instance, let’s say we have a list of customer names we want to add to our template. Here’s a JSON representation of that list:
[
{
"firstName": "Oliver",
"lastName": "Smith"
},
{
"firstName": "Sophia",
"lastName": "Williams"
},
{
"firstName": "Liam",
"lastName": "Johnson"
}
]
Create a bullet list and add tokens {{firstName}}
and {{lastName}}
there, then start the generation process.
Template:
Result:
See Lists for more complex scenarios.
The same approach works for tables:
Template:
Result:
See Tables for more complex scenarios.