Skip to main content

Set variable

Anatomy

<set var="var" key="(no key)">
string
</set>

Description: SET sets the value of a variable.

These three statements are semantically equivalent:

value value value

These two statements are semantically equivalent:

value value

Attributes

NameTypeDescriptionDefined By
varvarVariable name set
keystringKey set

Results:

BindingTypePredicate
varstringN/A

Examples

Setting regular variables

<set var="firstname">Bill</set>
<set var="lastname">Gates</set>
<output>$firstname $lastname</output>
<!-- Bill Gates -->

Setting array items implicitly

<set var="names[bg]">Bill Gates</set>
<set var="names.sj">Steve Jobs</set>
<output>$names.bg and $names[sj] are competitors!</output>
<!-- Bill Gates and Steve Jobs are competitors! -->

Setting array items explicitly

<set var="names" key="bg">Bill Gates</set>
<set var="names" key="sj">Steve Jobs</set>
<output>$names.bg and $names[sj] are competitors!</output>
<!-- Bill Gates and Steve Jobs are competitors! -->