Logical operators in Closure Templates
-
19-06-2021 - |
Question
I'm playing with Google Closure Templates
and I'm unable to successfully compile some templates because it seems that the logical "and" and "or" operators can't be used inside the if tag (I tried both "&&" and "and" and "||" and "or")... how can I write a "complex" if statements like: {if condition1 && condition2}
?
EDIT:
The following simple statement raises an exception:
{if 5 > 2 && 2 == 2}
"Not all code is in Soy V2 syntax (found tag {if 5 > 2 && 2 == 2} not in Soy V2 syntax)"
Solution
According to the latest version of the docs, use can use and
and or
as logical operators:
{if $x > 1 and $y < 1}
...
{elseif $x < 1 or $y > 2}
...
{/if}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow