How can I compare a view token with a string? I have a view token
{{ field_category }} == Content: Category
I need a condition like
if field category == &quot;Foo &amp; Bar&quot;
do something
else
do something
I wrote code
         {% if field_category == &quot;Foo &amp; Bar&quot; %}

             string1            
         {% else %}
        
            string 2
        
        {% endif %}

But it always goes for the else part even if the token value is &quot;Foo &amp; Bar&quot;
Please help to find a solution
But it always goes for the else part even if the token value is &quot;Foo &amp;
Bar&quot;

This is because by default Views adds classes to your field:

Which means field_category is actually equal to &lt;div class=&quot;some-class&quot;&gt;Foo &amp; Bar&lt;/div&gt;
and since &lt;div class=&quot;some-class&quot;&gt;Foo &amp; Bar&lt;/div&gt; is not equal to Foo &amp; Bar your conditional always goes to the else.
If you uncheck the &quot;Add default classes&quot; in your category field settings, your conditional should work now. Unless... your field is linking to something so it would still be &lt;a href=&quot;/some-url&quot;&gt;Foo &amp; Bar&lt;/a&gt; and not equal.
As 4k4 commented, you can instead use field_category__value to get the raw value and not have to uncheck the &quot;Add default classes&quot;.