Skip to main content

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 -->

true | false | cast

Truthiness rules

Different values convert to boolean as follows:

ValueBoolean equivalent
undefinedFALSE
NULLFALSE
FALSEFALSE
TRUETRUE
0 (int)FALSE
0.0 (float)FALSE
Any other numberTRUE
'' (empty string)FALSE
'0' (string zero)FALSE
Any other stringTRUE
Any arrayTRUE
note

The string "0" is falsy when cast to boolean — this catches many developers off guard. Always use explicit type checking with is or typeof when the distinction matters.

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 -->