if
¶
The Twital instruction for Twig’s if
tag is the``t:if`` attribute.
<p t:if="online == false">
Our website is in maintenance mode. Please, come back later.
</p>
elseif
and else
are not well supported, but you can always combine Twital with Twig.
<p t:if="online_users > 0">
{%if online_users == 1%}
one user
{% else %}
{{online_users}} users
{% endif %}
</p>
But if you are really interested to use elseif
and else
tags with Twital
you can do it anyway.
<p t:if="online">
I'm online
</p>
<p t:elseif="invisible">
I'm invisible
</p>
<p t:else="">
I'm offline
</p>
This syntax will work if there are no non-space charachters between the p
tags.
This example will not work:
<p t:if="online">
I'm online
</p>
<hr />
<p t:else="">
I'm offline
</p>
<p t:if="online">
I'm online
</p>
some text...
<p t:else="">
I'm offline
</p>
Note
To learn more about the Twig if
tag, please refer to Twig official documentation.