Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

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.3k
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