Class DirectiveNode.ForEachNode

Enclosing class:
DirectiveNode

static class DirectiveNode.ForEachNode extends DirectiveNode
A node in the parse tree representing a #foreach construct. While evaluating #foreach ($x in $things), {$code $x} will be set to each element of $things in turn. Once the loop completes, $x will go back to whatever value it had before, which might be undefined. During loop execution, the variable $foreach is also defined. Velocity defines a number of properties in this variable, but here we only support $foreach.hasNext.
  • Field Details

  • Constructor Details

  • Method Details

    • evaluate

      Object evaluate(EvaluationContext context)
      Description copied from class: Node
      Returns the result of evaluating this node in the given context. This result may be used as part of a further operation, for example evaluating 2 + 3 to 5 in order to set $x to 5 in #set ($x = 2 + 3). Or it may be used directly as part of the template output, for example evaluating replacing name by Fred in My name is $name..
      Specified by:
      evaluate in class Node