IF == true OR b == true statement

I cannot find a way to get TWIG to interpret the following conditional statement:

{% if a == true or b == true %} do stuff {% endif %} 

Am I missing something or is it impossible?

+43
twig
Nov 29 2018-11-11T00:
source share
2 answers

Check out this Twig Reference .

You can do it this simple:

 {% if (a or b) %} ... {% endif %} 
+99
Nov 30 '11 at 14:45
source share
— -

Comparison expressions must be in their brackets:

 {% if (a == 'foo') or (b == 'bar') %} ... {% endif %} 

Alternative if you are checking one variable and the number of possible values:

 {% if a in ['foo', 'bar', 'qux'] %} ... {% endif %} 
+11
04 Sep '16 at 17:29
source share



All Articles