The shorthand notation of a variable consists of a leading "$" character followed by a
VTL Identifier
. A VTL Identifier must start with an alphabetic character (a ... z
or A ... Z). The rest of the characters are limited to the following types of
characters:
- alphabetic (a .. z, A .. Z)
- numeric (0 .. 9)
- hyphen ("-")
- underscore ("_")
Here are some examples of valid variable references in the VTL:
$foo
$mudSlinger
$mud-slinger
$mud_slinger
$mudSlinger1
When VTL references a variable, such as $foo
, the variable can get its value from
either a set
directive in the template, or from the Java code. For example, if
the Java variable $foo
has the value bar
at the time the template is
requested, bar
replaces all instances of $foo
on the Web page. Alternatively, if you include the statement
#set ($foo = "bar")
The output will be the same for all instances of $foo that follow this directive.