if


Like case and unless tags, if tags controls the display of information based on a condition


Syntax


{% if <Conditions> %}

<Template Block>

{% endif %}



Arguments

Condition - An expression that must resolve to a true or false value. Display of the template block occurs only if the condition returns true.


Boolean Operators

These operators combine conditions together

  and - Both conditions must evaluate to true

  or - At least one condition must evaluate to true


Comparison Operators

These operators typically compare parameters with a set value

  == - Used with strings or numerical values. Returns true if the left side of the condition equals the right side

  != - Used with numerical values. Returns true if the left side of the condition does not equal the right side

  <> - Used with numerical values. Returns true if the left side of the condition does not equal the right side

  < - Returns true if the left side of the condition is numerically less than the right side

  <= - Used with numerical values. Returns true if the left side of the condition is numerically less than or equal to the right side

  > - Used with numerical values. Returns true if the left side of the condition is numerically greater than the right side

  >= - Used with numerical values. Returns true if the left side of the condition is numerically greater than or equal to the right side

  contains - Used with strings or array values. Returns true if the left side of the condition includes the right side of the condition within it.


Helper Tags

Within an if template block, there are handful of optional tags available:

  elseif

  else


Example:

InputParameter Value


'Orange'



Input


My favorite animal is:{% if InputParameter == 'Orange' %}

Fox

{% endif %}



Output


My favorite animal is:

Fox