Microsoft Word Templates¶
Getting started with Microsoft Word Templates¶
Microsoft Word Templates enables you to merge data provided by various services with templates and produce Microsoft Word documents as a result.
Template:
Created document:
Template creation¶
A Template is a regular Microsoft Word document (.docx file) with special tags in its text that determine where and how to merge/fill in data. There are three types of tags: Simple value, Condition and Loop or section.
Simple value¶
A Simple value tag is simply replaced with a corresponding value. The tag's name corresponds to the Key
field's value, which is placed inside double curly braces: e.g. {{name}}
.
Template:
1 |
|
Module's setup:
Created document:
1 |
|
Condition¶
A Condition tag enables you to wrap certain parts of a text that should be rendered conditionally. To wrap the conditional text, place it between the opening and closing tags. The name of the opening tag is prepended with a hash sign #
, the name of the closing tag is prepended with a slash /
.
Template:
1 2 |
|
Module's setup:
Created document:
1 |
|
Loop or section¶
A Loop or section tag enables you to repeat parts of a text. Similarly to the Condition tag, to wrap the repeated text, place it between the opening and closing tags. The name of the opening tag is prepended with a hash sign #
, the name of the closing tag is prepended with a slash /
.
When using loops, you can choose to employ either the Fill out a document module or the Fill a document with a batch of data aggregator module.
Fill out a document¶
If you employ Fill out a document module, the content of the field Value has to be an array of collections, where:
-
Each collection corresponds to one data entry and contains one item
entry
-
Item
entry
contains a collection with two itemskey
andvalue
-
Item
key
contains the tag's name -
item
value
contains the tag's value
Template:
1 2 3 |
|
Module's setup:
Created document:
1 2 |
|
You can also execute a loop to populate a table. The example below shows how to create such table in a template:
Fill a document with a batch of data¶
If your data entries come as separate bundles, you may prefer to employ the Fill a document with a batch of data aggregator module. You can employ this module also if your data entries come as an array - just employ the Iterator module to transform the content of the array to a series of bundles.
The main advantage of the Fill a document with a batch of data module is that it enables you to easily setup the structure required for the Value field and map items to each value
item. In contrast to the Fill out a document module, the field Values contains only a single entry, the actual entries will be created and populated for each incoming bundle. The template will be produced after all input bundles have been processed. The aggregator module is useful especially when creating lists or reports.
Example: Export Google Contacts into a table
The first module loads the template. The next module retrieves all contacts from the specified group in Google Contacts. The aggregator module then aggregates all values retrieved from Google Contacts and merges them into the template. Finally, the last module will save the filled template to a desired location.
Template:
Module's setup:
Created document:
------------------------------------- |