Reusing Template with Inline or Reference
You may want to produce same content under different templates. If you duplicate the same template code in multiple templates, you need to spend extra time and effort in keeping them consistent with each other. In such a case, you can create one template, and reuse it in other templates. The reuse of template can be done by using <Reference> and <Inline>. The following example show the use of <Reference> and <Inline> in a template.
<Reference template="Children (General)"/>
The example above means that when <Inline> is met, substitute that part with content written in the Children (General) template. Same for <Reference>.
Inline vs Reference
Both <Inline> and <Reference> support the reuse of templates. They work nearly identically except one important difference - The way they handle dynamic heading style.
Dynamic heading style, as its name suggest, supports the dynamic assignment of heading style to text content. If you use <Inline> and in the referencing template a @heading+ is used, the leveling of active heading style will be increased by one. Once the referencing template has ended and the flow flows back to the source template, the leveling of heading style will remain as-is, which means, same as the leveling used by the last heading defined in the referencing template.
What makes <Reference> different is that when its flow ends and flows back to the source template, the leveling of heading style will be reset to that before entering the referencing template.
Let's explain with an example. Here a template Bar.
Here is another template Foo. It references the Bar template above.
In Bar, several @heading+ has been used, which trigger the increases of the leveling of heading style. You can expect that in the end the text Result printed by Foo will be in Heading 4 because it follows last style used by the template referencing inline.
If we change <Inline> to <Reference>, the text Result will be in Heading 1, following the style last used within Foo.
The following resources may help you to learn more about the topic discussed in this page.
|11. Working with other DCTL Constructs||Table of Contents||13. Using variables in Doc. Composer|