Tags are close between curly brackets. For example, given (in .docx):
This Procedure is for {name}
And the data (in .json)
{
"name": "Sales Process"
}
The output in the .docx will be
This Procedure is for Sales Process
Sections
Sections begin with a pound (#) and end with a slash (/). For example, {#process} begins a “process” section while {/process} ends it.
Depending on the type of the data, sections will behave differently.
Type of Data | Behaviour | Scope |
---|---|---|
boolean | Conditional – section is shown if true | unchanged |
empty array | Section not shown | – |
non empty array | For each element of the array | element of the array |
object | Section is displayed once for the object | object |
Conditionals
Conditionals start with a pound (#) and end with a slash (/). Conditionals can be used to show content based on a whether an attribute is true or false.
Given this syntax in the template (.docx)
This role is {#responsible}Responsible{/responsible}{#accountable}Accountable{/accountable}
And this data (.json)
{
"responsible": false
"accountable": true
"name": "Accounting Clerk"
}
The following will be rendered
This role is Accountable
In addition to using free text, you can also use tags within conditional statements to dynamically display information. For example, give this syntax:
Who is responsible for this task? {#accountable}{name}{/accountable}
And the same data given above, the following will be rendered
Who is responsible for this task? Accounting Clerk
If we had replaced {#accountable}...{/accountable} with {#responsible}...{/responsible}
, “Accounting Clerk” would not have been printed, since responsible is false.
Loops
The syntax for loops and conditionals are the same. Loops should be used where data is stored in arrays. Given this syntax (in .docx):
{#rules}
{name}
{/rules}
and the following data (in .json)
{
"rules":[
{ "name": "Perform Background Checks" },
{ "name": "Sign Contract on First Day" },
{ "name": "Change Employee Passwords every 3 Months" }
]
}
The rendered output will be:
Perform Background Checks
Sign Contract on First Day
Change Employee Passwords every 3 Months
Inverted Sections
Inverted sections start with a caret (^) and ends with a slash (/). An inverted section is essentially an else statement. Give this syntax (in .docx)
{#goal}goal{/goal}
{^goal}No goal has been defined{/goal}
and this data (in .json)
{
"goal": null
}
The following output will be rendered
No goal has been defined
Hinterlasse einen Kommentar.