static class DirectiveNode.SetNode extends DirectiveNode
#set construct. Evaluating
#set ($x = 23) will set $x to the value 23. It does not in itself produce
any text in the output.
Velocity supports setting values within arrays or collections, with for example
$set ($x[$i] = $y). That is not currently supported here.
DirectiveNode.ForEachNode, DirectiveNode.IfNode, DirectiveNode.MacroCallNode, DirectiveNode.SetNode| Modifier and Type | Field and Description |
|---|---|
private Node |
expression |
private java.lang.String |
var |
lineNumber| Constructor and Description |
|---|
SetNode(java.lang.String var,
Node expression) |
| Modifier and Type | Method and Description |
|---|---|
(package private) java.lang.Object |
evaluate(EvaluationContext context)
Returns the result of evaluating this node in the given context.
|
cons, emptyNode, evaluationException, evaluationExceptionprivate final java.lang.String var
private final Node expression
SetNode(java.lang.String var,
Node expression)
java.lang.Object evaluate(EvaluationContext context)
Node2 + 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..