A brief introduction to how EnterWorks uses Velocity Template Language (VTL).
The Velocity Template Language (VTL) is meant to provide the easiest, simplest, and cleanest way to incorporate dynamic content for the mapping of publication content. Even a user with little or no programming experience should be able to use VTL to incorporate dynamic content in a publication layout mapping.
EnterWorks uses VTL to reference, concatenate, and embed dynamic content (PIM attributes) along with scripting logic to control output mappings. Here is an example of a VTL statement that could be embedded in a mapping statement:
#set ($a ="Velocity")
Like all VTL statements, this statement begins with the #
character and
contains a directive: set
. When an online visitor requests your Web
page, the Velocity Templating Engine will search through your Web page to find all
#
characters, then determine which mark the beginning of VTL
statements, and which of the #
characters that have nothing to do with
VTL.
The #
character is followed by a directive, set
. The
set
directive uses an expression (enclosed in brackets) -- an
equation that assigns a value
to a variable
. The
variable is listed on the left hand side, and its value is listed on the right hand
side; the two are separated by an =
character.
In the example above, the variable is $a
and the value is
Velocity
. This variable, like all references, begins with the
$
character. String values are always enclosed in quotes, either
single or double quotes. Single quotes will ensure that the quoted value will be
assigned to the reference as is. Double quotes allow you to use Velocity references and
directives to interpolate, such as "Hello $name", where the $name
will
be replaced by the current value before that string literal is assigned to the left hand
side of the =
The following rule of thumb may be useful to better understand how Velocity works:
References begin with $ and are used to get something. Directives begin with # and are used to do something.
In the example above, #set
is used to assign a value to a variable. The
variable $a
can then be used in the template to output "Velocity."