It’s an object so if the object exists then it will evaluate to true - just like it would in PHP.
There's a special templater function called
empty
that can be used to evaluate such things:
HTML:
<xf:set var="$preEscaped"></xf:set>
{{ dump($preEscaped) }}
<xf:if is="empty($preEscaped)">
Empty
<xf:else />
Not empty
</xf:if>
This will output "Empty".
HTML:
<xf:set var="$preEscaped">Test</xf:set>
{{ dump($preEscaped) }}
<xf:if is="empty($preEscaped)">
Empty
<xf:else />
Not empty
</xf:if>
This will output "Not empty".
It's worth noting that if you can "trust" or you handle the escaping of the original value yourself, then you can just do this:
HTML:
<xf:set var="$var" value="" />
{{ dump(var) }}
<xf:if is="!$var">
Empty
<xf:else />
Not empty
</xf:if>