MagicDraw 18.5 Documentation
Define a child template that you will use as in examples 1, 2, and 3. This child template contains the following header line and named sections ('Section A' and 'Section B'):
Usage in Example 1
This example shows how to statically include the complete child template as shown in the Preparatory Step. To include it, call the $import.include('child.rtf') method. Note that there is no specified path, this path to the child template tells you that the main and child templates reside in the same directory.
The output right below will include the entire text from the main template (right above) and from the child template (see the Preparatory Step) minus the template directives. The included content will be then parsed and stripped of all velocity directives. The output is as follows:
Usage in Example 2
This example shows how to statically include a section of the child template as shown in the Preparatory Step. To include the section, named 'Section A' from the child template, call the $import.includeSection('templates/child.rtf', 'Section A') method. In this example, the main and child templates reside in different directories, which means that the child template will reside in a subdirectory called 'templates'. This 'templates' directory will thus reside in the same directory as the main template.
The output will be:
Usage in Example 3
This example shows how to dynamically include the section of a child template as shown in the Preparatory Step. Before dynamically including the section of the child template named 'Section B', set a variable for the file location of the child template [#set ($child = "C:/ImportTool/child.rtf")] and another one for the section name to be included [#set ($section = "Section B")]. To include the ‘Section B’ section from the child template, call the $import.includeSection($child, $section) method. In this example, the child's template location is provided by an absolute path. Note that dynamic values must not be specified in a pair of quote marks, otherwise the section will not be included.
The output will be:
The Import Tool supports RTF, HTML, XML, and text files only.
- No labels