[#set name : type = value]
[#set name1 : type1 = value1 
      name2 : type2 = value2 
      nameN : typeN = valueN]
[#set name]
assigned value



The set directive declares and initializes variables for use within the template. With this you can create a new variable, or replace an existing variable. As a convenience feature, you can do more than one assignment with one set tag.

Note this directive doesn't allow you to update template parameters nor script parameters. In such case, you are recommended to define a new local variable initialized with a template or script parameter value; this local variable can then be updated at your convenience in the template body.


Creates a String variable and initializes its value:

[#set myString = "Hello World"]

Creates a List variable and initializes its value:

[#set seasons = ["winter", "spring", "summer", "autumn"]]

Create the two variables in one set directive:

[#set myString = "Hello World" 
      seasons = ["winter", "spring", "summer", "autumn"]]

Assigns the type of a UML operation to a variable:

[#set theType : uml21.Type = myOperation.type]

Assigns a multiline text to a variable:

[#set largeString]
Some multi line text
with dynamic text ${}