s:set

Set or reset a variable.

INPUT
<s:set var="x">
    3
</s:set> 
{{ x }}
OUTPUT
3
name=""  var=""  

Use one of these attributes to provide the variable name to `set`.

INPUT
<s:set var="x">
    1
</s:set>
<s:set name="y">
    2
</s:set>
{{ x }} + {{ y }} = 3
OUTPUT
1 + 2 = 3
no-trim=""  

By default, set removes all whitespace (spaces, tabs and newlines) from the beginning and end of the value.

You can use `no-trim=` to disable this feature.

INPUT
<s:set name="x" no-trim>
    3
</s:set>
1{{ x }} instead of 13.
OUTPUT
1 3 instead of 13.
constant=""  const=""  

Use one of these attributes to lock a variable from changing.

INPUT
<s:set name="x" const>
    3
</s:set>
<s:set name="x">
    4
</s:set>
OUTPUT
ERROR: Cannot reset a constant variable!
no-reset=""  if-unset=""  if-not-set=""  

Use one of these attributes to instruct set not to reset an existing variable -- do nothing if the variable already exists.

INPUT
<s:set var="x">
    3
</s:set>
<s:set var="x" no-reset>
    4
</s:set>
{{x}}
OUTPUT
3
append=""  

Instead of reseting a variable with a new value, append the new value to the current one.

INPUT
<s:set name="x">
    Hello
</s:set>
<s:set name="x" append no-trim>
    World!
</s:set>
OUTPUT
Hello World!
prepend=""  

Instead of reseting a variable with a new value, prepend the new value to the current one.

INPUT
<s:set name="x">
    Hello
</s:set>
<s:set name="x" prepend no-trim>
    World!
</s:set>
OUTPUT
World! Hello