script

Syntax

[#script visibility scriptName(parameters)]
body
[/#script]

where:


Each parameter is of the form:

name : type

where:

Description

The script directive defines the signature of a script, as well as the contents to be generated.

The signature of a script must be unique within its metatype. The signature is defined by the script's name and its number of parameters: two scripts defined on the same metatype can share the same name as long as they have different number of parameters.

The script may define expected parameters, used to compute the generated contents. Any caller of the script must provide matching arguments. The return type does not need to be defined here, as TGL scripts always return strings.

The self variable is available in the script contents. This variable is the instance the script is evaluated on (instance of the script's metatype).

Examples

This code defines scripts attached to the UML Class type:

[#package com.mycompany.example]

[#metatype uml21.Class]

[#script qualifiedName]
${self.namespace.name}.${self.name}[/#script]

[#script anotherScript]
...
[/#script]

Related concepts
Script