NextGen Knowledge Center

Basic Syntax

Basic syntax for a Velocity reference is as follows:

${variableName}

The brackets may be omitted if the identifier starts with a letter and contains only letters, numbers, hyphens, or underscores:

$variableName

The variable will be looked up in all available maps, according to The Variable Map Lookup Sequence. The string representation of the value will then replace the Velocity reference. You can also access properties and methods from context variables:

${myArray.length}
${myList.size()}
${myObject.customMethod('param')}

If a property has a corresponding getter method (like getValue()), the engine will automatically find that method when you attempt to access the property. Therefore these may be equivalent:

${myObject.value}
${myObject.getValue()}

If the context variable doesn't exist, or if the value returned by the reference evaluation is null, no replacement will be done, so the final template will still have your "${varName}" string within. In these cases you can put an exclamation mark after the dollar sign to tell the engine to replace null values with an empty string instead:

$!{thisValueIsNull}