{Expander}.stg
Defining the Expanders Template
The actual expanderExpanderA unit of generation that combines a data tree instance (functional M1 model) with a template to generate an artifact. template is defined in an .stg file. The template uses variables, which are filled with model data during expansion. These variables are defined in the mapping file.
A template example:
base() ::= <<
package <packageName>;
// @expanderComment@
public void <dataElement>Foo {
}
>>
This requires the values packageName and dataElement, which can be defined in the mapping with ognl expressions:
<?xml version="1.0" encoding="UTF-8" ?>
<mapping xmlns="https://schemas.normalizedsystems.org/xsd/expanders/2023/0/0/mapping">
<value name="dataElement" eval="dataElement.name"/>
<value name="packageName" eval="dataElement.packageName"/>
</mapping>
Now the expanderExpanderA unit of generation that combines a data tree instance (functional M1 model) with a template to generate an artifact. will extract the values for both variables based on the eval expressions
Testing the base content of an expander
A guide to test a template can be found in the developer hub: Implement Template