We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

ternary operator in volt

How to use ternary operator in volt for below example

{% pageType == 'basicSetting' ? 'class="active"' : '' %}

To output a value use {{ and }} not {%%}

I want to use ternary operator....give me proper example



6.4k
Accepted
answer

What I meant is that your sentence makes no sense, you are using the ternary operator well, but not tags

Try


{% set pageType = 'basicSetting' %}
{{ pageType == 'basicSetting' ? 'class="active"' : '' }}

working thnx