Example of Using Variables in DOCX Template

This section presents sample logic and templates showing how variables can be used. For a general description how to create a DOCX template, see About Publishing to DOC or PDF.

The following variables are used in the sample:

  • Simple variable

  • Repeated variables

  • Repeated table row

  • Variables used for condition statement (e.g., block)

  • Else if statement

You can also insert a complex XML with formatting, as shown in this demo: https://docxtemplater.com/demo/#xml-insertion

Sample element code for repeated variables (returns an array of maps)
def arrayMaps = []; arrayMaps << [name:'Amy', price: 54] arrayMaps << [name:'Amy2', price: 154] arrayMaps << [name:'Amy3', price: 255] arrayMaps << [name:'Amy4', price: 367] return arrayMaps

Download the sample logic and template.

Found an issue in documentation? Write to us.

 
Pricefx version 13.1