Directive tags are instructions to process a template and will not be output. They use an HTML-like syntax:
The format of the parameters depends on the directive used.
Some directives (e.g.
package) do not accept nested content,
i.e. code between start tag and end tag.
In that case, you only need to use the start tag (e.g.
The tag delimiter characters are
This is particulary useful to generate HTML or XML file, to avoid confusion between TGL directives and HTML tags:
[#template GenerateXMLFile(option : boolean)] <?xml version="1.0" encoding="UTF-8"?> <contents> [#if option] <on/> [#else] <off/> [#/if] </contents> [/#template]
|Most commonly used directives|
|guard||Conditionally skips the evaluation of a text template or of a script body.|
|file||Defines the name of the file where the text generated by a text template will be written.|
|foreach, break||Processes a section of the template for each element contained within a collection.|
|if, else, elseif||Conditionally skips a section of the template.|
|import||Makes the referenced element (text template, ruleset or Java type) directly available in the template.|
|include||Evaluates a referenced text template and inserts the resulting text at the current position.|
|metatype||Specifies the metatype for which the contained scripts apply.|
|package||Defines the namespace of text templates and of scripts.|
|Specifies sections in the generated text where any user manual modification must be preserved.|
|script||Defines the signature of a script, as well as the contents to be generated.|
|set||Declares and initializes variables for use within the template.|
|template||Defines the signature of a text template, as well as the contents to be generated.|
|while, break||Processes a section of the template while a condition is true.|
|attempt, recover||Provides alternate processing in case an error occurs.|
|compress||Removes superfluous white-space for white-space insensitive formats (e.g. HTML or XML).|
|library||Defines the name of the library, as well as the macros it contains.|
|macro||Defines the signature of a macro, as well as the contents to be generated|
|noparse||Causes the contained text to be skipped by the parser and output directly|
|stop||Aborts the evaluation process.|
|tab||Shifts right using a tab character a section of the template.|
|trim, ltrim, rtrim, notrim||Instructs the engine to ignore certain whitespace characters in the line of the directive.|
|using||Makes the macros defined in the referenced library directly available in the template.|