Velocity¶
- Table of contents
- Velocity
Easy templating language for the non geek¶
Velocity is the world's easiest templating tool.
Using it within HTML helps to clearly separate your presentation from your business logic, and a "report designer" or "web page designer" will only need to learn 4 special characters: $ ! . # (that's no swearing ;-)
And as a developer, you will only need to learn a grand total of 9 directives to use the full power of Velocity in your own reports.
Details¶
$ (dollar sign) = a variable¶
A dollar sign in front of a word (of any length) instructs Velocity that this word is in fact a variable.
Variables are replaced with content that you provide from within Servoy.
- $foundset
- $my_chart1
- $myVeryLongVariableNameHere
. (dot) = object notation¶
Standard object notation allow for accessing object properties and methods, just like Servoy, and with any Servoy variables.
For example:- $foundset.id
- $rec.relation_to_child.name
- $dataset.oneField
etc.
! (exclamation mark) = the silent mark¶
If you are unsure whether or not a variable will exist at runtime (it might be null), you can use the ! exclamation mark to tell Velocity not to output anything.For example:
- $!foundset
- $!my_chart1
- $!myVeryLongVariableNameHere
! (exclamation mark) = negation¶
The ! exclamation mark can also be used as a negation in tests, for example:
#if(!$test)
// do something
#end
# (hash symbol) = velocity directive¶
The # hash symbol is reserved for denoting Velocity directives. These directives are self-explanatory and are listed below:- #if
- #else
- #elseif
- #end
- #set
- #foreach
- #include
- #parse
- #macro
Note: Velocity also provides a means for you to create special functions and use them as macros anywhere in your templates.
Check the velocity user guide to know more about some extended options:
http://velocity.apache.org/engine/releases/velocity-1.7/user-guide.html