Microsoft Word or LibreOffice Writer templates
Both Microsoft Word and LibreOffice Writer are supported as software for template creation. Compatibility with templates created in other software is not guaranteed.
Template should be designed and saved as an ordinary .docx
document.
For all dynamic data and templating commands it is highly advised to use MergeField, proper template processing is not guaranteed otherwise.
To add new MergeField command to the document:
- Click where you want to place a MergeField.
-
In the
Insert
tab, clickQuick Parts
and thenField
.
-
Under
Field names
, select MergeField.
-
Type your command under
Field properties
>Field name
, pressOk
button
Example templates with Velocity
syntax: sample_employees.docx, sample_weekly.docx
Template should be designed and saved as an .odt
document.
For all dynamic data and templating commands it is highly advised to use Input field, proper template processing is not guaranteed otherwise.
To add new Input field command to the document:
-
Click where you want to place a Input field.
-
Click
Insert
, clickField
and thenMore Fields
(orCtrl+F2
).
-
Select
Functions
tab, then select Input field underType
and pressInsert.
-
Write your command into big input box and click
Ok
.
Example templates with Velocity
syntax: sample_employees.odt, sample_weekly.odt
Templating language
Velocity is used as template processor, for more details, please consult the Velocity user guide.
-
To print a value, use: $VARIABLE_NAME.
For example, to printtitle
:
$title
-
For conditional output, use (
#if(CONDITION)
#else
#end
).
For example, to printtitle1
ifflag
variable is set to true and-
otherwise:
#if($flag)
$title
#else
-#end
-
Use loops to output arrays/lists: (
#foreach($ELEMENT_NAME in $ELEMENTS_ARRAY_NAME)
#end
).
For example, to printlastName
of every Customer incustomers
array:
#foreach($customer in $customers)
$customer.lastName
#end
-
Tables work a bit different. You want to output table rows, but it's not possible to add commands in-between rows in MS Word or LibreOffice Writer.
To handle tables, two suffixes are provided:
@<
, if added to the command anywhere inside a table row, will have this command interpreted as if it were set before the row.
@>
is the exact opposite suffix, which will have a command interpreted as if it were placed after the row.
For example, to printfirstName
andlastName
of every Person in thepersons
array, each pair in a new row: