Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This section explains the examples of usage of the master main and child templates. These examples allow you to create documents as the master main template and reuse the content of child templates into it.

...

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.docx') method. Note that there is no specified path. This path to the child template shows you that the master main and child templates reside in the same directory. Type the following lines in the document that you want to include all of its content to the report:

Code Block
languagetext
#import ('import', 'com.nomagic.reportwizard.tools.ImportTool')
This is the 1st mastermain template
Include child template
$import.include('child.docx')

The output right below will include the entire text from the master main template (right above) and from the child template minus the template directives. The included content will be then parsed and stripped of all velocity directives. The output is as follows:

Code Block
languagetext
This is the 1st mastermain template
Include child template
This is the child template.
This is Section A.
This is Section B.

...

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 master 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 master main template. Type the following lines in the document that you want to include its content in Section A to the report:

Code Block
languagetext
#import ('import', 'com.nomagic.reportwizard.tools.ImportTool')
This is the 2nd mastermain template
Include Section A
$import.includeSection('templates/child.rtf', 'Section A')

...

Code Block
languagetext
This is the 2nd  mastermain template
Include Section A
This is Section A.

...

Code Block
languagetext
#import ('import', 'com.nomagic.reportwizard.tools.ImportTool')
This is the 3rd mastermain template
Include Section B
#set ($child = "C:/ImportTool/child.rtf")
#set ($section = "Section B")
$import.includeSection($child, $section)

...

Code Block
languagetext
This is the 3rd mastermain template
Include Section B
This is Section B.

...