Master/Sub Templates

Category : Technical Examples

Templates can be combined into one resulting document, allowing content that appears in multiple documents to be separated out into a "shared" or common template.


Template
Data Files
Output Files
All Files as a ZIP

This example explained

NOTE: This example relies on multiple template files, which can be found in the "MasterSubTemplates.zip" download above.

1) Direct Referencing

A child/sub template maybe inserted into a parent/master template by directly naming the child template inside the parent template using the "ref:" instruction, like this:

<<ref:common/template1.doc>>

Docmosis will look for the "template1.doc" template in the the "common" folder.  The path to the child template should be given relative to the location of the parent template.  Docmosis will insert the content from "template1.doc" at the position of the <<ref: field in the parent template.

The template being included is a complete Docmosis template, and can include everything a normal template may include, with the exception of header and footer content.

2) Indirect Referencing

If the child template to be included is to be determined at run time, you may pass the filename in the data instead.

In this case you use the "refLookup:" field:

<<refLookup:templateName>>

This will insert the template whose filename is in the data element "templateName".