The PowerDesigner Generation Template Language (GTL) is a template-based language, which is used to generate text for the metaclasses defined in the PowerDesigner metamodel, and on any extensions that are defined in the model profile.
Each template is associated with a given metaclass (for example, a CDM entity attribute, a PDM table, or an OOM operation). You can define as many templates as you want for each metaclass, and they will be available to all objects (instances) of the metaclass.
When you generate a model, PowerDesigner evaluates which metaclasses must have files generated, and creates a file for each instance of the metaclass, by applying the appropriate templates and resolving any variables.
GTL is object-oriented, and supports inheritance and polymorphism for reusability and maintainability. Macros provide generic programming structures for testing variables and iterating through collections, etc.
To examine the set of templates used to generate code for operations in a Java OOM, open the Java object language in the resource editor and expand the Profile\Operation\Templates category.
A GTL template can contain text, macros, and variables, and can reference:
GTL templates can be either simple or complex
A simple template can contain text, variables, and conditional blocks, but cannot contain macros. For example:
%Visibility% %DataType% %Code%
When this template is evaluated, the three variables Visibility, DataType, and Code will be resolved to the values of these properties for the object.
A complex template can contain any element from a simple template, and also macros. For example:
.if (%isInner% == false) and ((%Visibility% == +) or (%Visibility% == *)) [%sourceHeader%\n\n]\ [%definition%\n\n] .foreach_item(ChildDependencies) [%isSameFile%?%InfluentObject.definition%\n\n] .next [%sourceFooter%\n] .endif
This template begins with an .if macro which tests the values of the isInner and Visibility properties. Several variables are enclosed in square brackets, which ensures that the text enclosed with them (in this case, new line characters) will not be generated if the variable evaluates to void. The .foreach_item macro loops over all the members of the ChildDependencies collection.