A Velocity directive is a keyword used by Velocity to perform certain tasks such as looping and controlling the output of the document based on values from MagicDraw.
With directives you can make dynamic templates and you can do more than just print out MagicDraw elements and attributes. A Velocity directive begins with # and followed by the directive name. Some of the frequently used Velocity directives are as follows:
- #if, #elseif, and #else: these directives are used to decide whether or not text should be included in the output based on the conditional statement.
- #set: this directive is used to assign a value to a variable.
- #foreach: this directive is used to iterate through a list of variables.
- #macro: this directive is used as a means to create a reusable script. It is especially useful if you need to call a certain line of scripts repeatedly.