javascriptgoogle-closure-templates

Logical operators in Closure Templates


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}