Basic Velocity Examples

The following examples show how the notification template properties may be used in common Velocity statements.

  1. If-then-else statement in general form:

    #if (CONDITION)

    ***Statements/HTML to output

    #else

    ***Statements/HTML to output

    #end

    Checking null values:

    #if ($snapshot)

    <tr><td>Snapshot:</td>

    <td>$snapshot.getName()</td>

    </tr>

    #end

  2. Creating a new variable; setting the new value to an existing variable:

    #set ($var = "odd")

  3. Iterating collections:

    #foreach ($item in $collection)

    ***Statements/HTML to output

    #end