Templ4docx 2.0.0 - Text Variables
The most common situation is when we want to replace simple text variable. Imagine that you have an invitation template and you want to prepare filled invitation with firstname and lastname. So the only thing you need is to find variables in the template and then replace them with the correct values. Suppose that the variables in the template are as follows: ${firstname} and ${lastname}. This pattern of variables is the default one for templ4docx and does not require to define it. However, if the variables in the template have a different form, for example: #{firstname}, you must tell to templ4docx how they look like. In this case you must define the object VariablePattern
in the following way new VariablePattern("#{", "}")
and then set it to Docx object:
At this point you are ready to play with template.
Text variables may be placed anywhere: in a paragraph, table cell, numbered \ bullet list … The important thing is that style of text is preserved. So if you want to create, for example bolded lastname, just create bolded variable #{lastname}.