The MergeTemplate Function
When XpressDox encounters a «MergeTemplate()» function while running a template, it will keep the template name (which is passed to the function) in a list, called the Templates to Merge List. After completing the main template, all the templates in the Templates to Merge List will then be run, using the same data set as was used for the main template. This functionality is almost exactly the same as the RunTemplates command, except that with MergeTemplate, an interview is not presented to the user for each such template, as the data for the previous template is used.
The argument to the function is the name of the template to be merged, which can be any one of the following:
- a hard-coded name, in which case it must be in quotes:
«MergeTemplate('letters:Letter to Borrower')»
- the name of the template can be contained in a data element:
- the name can be constructed out of the contents of data elements and/or variables and/or constants:
«MergeTemplate(concat('letters:Letter to ',PartyType))»
Execution of the
«MergeTemplate()» function can be conditional, i.e. subject to an «
If()» command, e.g.
«If(IncludeSpouse = "Y")»«MergeTemplate('Letter to Spouse')»«End()»
In addition, any template referenced in a MergeTemplate() function can itself call MergeTemplate().
The extra templates merged from the Templates to Merge List will each be merged, and saved, into their own separate file.
Note that the paragraph in which the
«MergeTemplate()» command appears will be deleted from the main document.