Link Templates

Home > Model Transformation > Model-to-Text (M2T) > OOMEGA Generator > Link Templates

Templates might contain template code fragments which are useful for other templates, too. In order to avoid redundancies these code fragments can be sourced out to templates which in turn can be included by one or more templates afterwards. Moreover it is possible to parameterise templates, i.e. to include templates and pass one or more parameters during inclusion/invocation.

Template inclusion/invocation is quite simple. The following code fragment includes the template attributes.include.jgen and passes the parameters ec and 2 to it.

<% include("attributes.include", ec, 2); %>

It is not obligatory to suffix includable templates with ".include", nevertheless we recommend to do so as you are immediately aware of all the templates which are used within other templates.

Parameters should be evaluated in includable template files. They are accessible via the parameters array as shown in the following code fragment.

<% ec = (EntityClass) parameters[0];
   int indent = ((Integer) parameters[1]).intValue();
%>

Next chapter: Build Targets

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.