Booleans
The Boolean type (bool) represents a truth value — either TRUE or FALSE.
- Neutral literal:
FALSE - typeof result:
'bool'
Creating booleans
Booleans are typically produced by comparison operations, type checks, or explicit commands:
XML
<!-- Explicit boolean values -->
<true var="flag" /> <!-- TRUE -->
<false var="flag" /> <!-- FALSE -->
<!-- Cast from other types -->
<set var="x">1</set>
<cast var="x" type="bool" /> <!-- TRUE -->
Truthiness rules
Different values convert to boolean as follows:
| Value | Boolean equivalent |
|---|---|
undefined | FALSE |
NULL | FALSE |
FALSE | FALSE |
TRUE | TRUE |
0 (int) | FALSE |
0.0 (float) | FALSE |
| Any other number | TRUE |
'' (empty string) | FALSE |
'0' (string zero) | FALSE |
| Any other string | TRUE |
| Any array | TRUE |
note
Booleans in conditionals
The <if> construct compares two values with a comparison function — it does not directly evaluate boolean truthiness. To check if a variable is truthy, compare it against an empty string:
XML
<if value1="$flag" func="!=" value2="">
<output>flag is truthy</output>
</if>
For type-based branching, use is:
XML
<is var="x" type="bool">
<output>x is a boolean</output>
</is>
Boolean to string
When cast to string, TRUE becomes "1" and FALSE becomes "" (empty string). This matters when outputting boolean values:
XML
<true var="flag" />
<output>Flag: $flag</output>
<!-- Flag: 1 -->