Syntax rules of the velocity macros

Velocity macros are subject to certain syntax rules.

Syntax of an instruction (velocity macro)

Description

$

Prefix for a variable. A variable is composed of $ and the variable name. This will output the contents of the variable.

Example: $objectName

$variablename

Definition of a variable. A variable name has the following structure:

  1. Character is a $ sign

  2. Character is upper or lower case (alphabetical)

  3. and all following characters must be characters from the following ranges: a-z,A-Z,0-9,_-

Example: $employee_role3

#

Prefix of a command

Example: #if

##

Single line comment

Example: ## This is a one line comment

#* ....... *#

Multiline comment

Example: #* This is a multiline comment ...'line 2'.... ...'Line10' *#

#set($variable=value)

Variable declaration. The variable is assigned a value.

Note: If the variable did not exist before, it is also defined here at the same time.

Example: #set($currency="€")

simple #if statement

#if(condition)[conditional statement=""]#end

The condition is enclosed in round brackets ( ). If the condition is true, then the conditional statement is executed.

The statement is enclosed in square brackets [ ] and will be executed if the condition is met.

Example:  

If the object category = "Employee", then the name of the employee is output:

#if($objectCategoryName=="Employee")[$objectName]#end

Example: If the short name of the object contains a value, then the short name is output:

#if($objectShortName)[$objectShortName]

Attention: The test to see if a variable contains a value should always be #if($variablename). The form #if($variablename!=" ") returns an error.

Example: For the output of "Object category: Object name", e.g. "Employee: Schmitt", use the following statement:

$objectCategoryName: $objectName

Note: For output without condition, make sure that the variable always has a value. For example, objects always have a label.

#if statement with else branch

#if(condition1)[bed. statement1=""] #else[statement2] #end

or

#if(condition1)[bed. statement1=""] #elseif(condition2)[bed. instruction2] #else[instruction3] #end

Example: An #if statement with else branch is suitable for the following case:

If the category of the object is a role, the role: "designation" is output,

otherwise: if the category of the object is an employee,
employee: "designation" is output,


otherwise: if no condition is met, "designation" is output.

To do this, use the following instruction:

#if($objectCategoryName=="Role")[Role: $objectName] #elseif($objectCategoryName=="Employee")[Employee: $objectName] #else[$objectName] #end

#forEach(variable in value-list) statement#end

The forEach loop traverses a list of values (array) and stores the current list value in a variable on each pass. This variable can be used in an instruction that is executed on each loop pass. The loop is finished when all list values have been processed.

Example: The forEach loop #foreach($daddy in $object.Parents) $daddy.VisibleName#end produces the following output:

$daddy = defined variable

$object.Parents = The "Parents" method outputs a list of values containing model objects of the "Object"class. One model object of the class"Object" is stored in the variable "$daddy" per run. "VisibleName" is a method of the "Object" class and outputs the name of the object.

==

Test for equality

!=

not equal (test for inequality)

III

Or-connection (no exclusive-or)

&&

And link