{true}
The constant TRUE: its content renders once, as a level of its own.
Syntax
{true}
{true} ... {/true}
Description
{true} answers TRUE - the plain hit of a level. Written as a pair, its content renders exactly once and there is no data to iterate; written alone it prints nothing. It is the fixed "yes" of the three constant tags, beside {false} and {null}.
Its use is as a neutral level to hang options on. Every tag takes the generic options, so {true tidy}...{/true} tidies a stretch of HTML, {true toContent='box'} keeps its rendered content in a store, and {true $total = 0}...{/true} gives a block a variable of its own that is unwound when the block closes. In tests it switches a branch on without changing anything else.
Because it is a hit, an @else@ part of a {true} never renders.
Examples
A block that always renders
The content of {true} renders once; flip it to {false} to switch the block off.
<p>Before.</p>
{true}
<p>This part is switched on.</p>
@else@
<p>Never shown.</p>
{/true}
<p>After.</p>
Before.
This part is switched on.
After.
A level for options
{true} as a neutral level: a variable of its own that is gone after the block.
{set $label = 'outside'}
{true $label = 'inside'}
<p>In the block: {$label}</p>
{/true}
<p>After the block: {$label}</p>
In the block: inside
After the block: outside