Multiple conditions for IF in Soy Template

4.3k Views Asked by At

I am using SOY V2 Templates in a project and have a need to use multiple conditions in an IF statement. I have been searching for a couple of hours and haven't found anything. Essentially I want to duplicate:

if (value !== null and value > 0)

I have tried:

{if $value != null & $value >0} {if $value != null && $value >0} {if $value != null, $value >0} {if $value != null; $value >0}

But all of these result in the error "not in SOY V2 Syntax". So right now I am nesting if statements and I don't think that is the best practice. Anyone know the correct way

1

There are 1 best solutions below

0
On

You're close. I think you're looking for:

/**
 * My template
 * @param value
 */
{template .myTemplate}
    {if $value != null and $value > 0}
      {$value} //renders the value in 'value'
    {/if}
{/template}

Operators are described here and if-statements are described here.