Using a simple variable
IdealDoc expressions are some contents enclosed by double curly braces {{}}
. In the below template, firstname
is a variable that is enclosed by double curly braces, which is said to be an expression.
{{firstname}} {{lastname}}
If the below input object is applied to the template.
{ firstname: "Yehuda", lastname: "Katz", }
Expressions are compiled to produce the output as follows:
Yehuda Katz
Path expressions
IdealDoc expressions can also be dot-separated paths.
{{person.firstname}} {{person.lastname}}
This expression looks up the person property in the input object and in turn looks up the firstname
and lastname
property within the person object.
Pass the below input object to the template.
{ person: { firstname: "Yehuda", lastname: "Katz", }, }{ person: { firstname: "Yehuda", lastname: "Katz", }, }
Output will be generated as below:
Yehuda Katz