Conditional Statements

Within a template, conditional decisions can be made based on the evaluation of a control expression.

Templex supports four conditional statements if, elseif, else, and endif.

Every conditional block begins with an if statement and ends with and endif statement. Within the if statement, the control expression inside the parentheses is evaluated first. If the value of the control expression is zero or false and there is an else statement, then the statement following the else statement is executed. If there is no else, the statement following endif is executed. If the value of the control expression evaluates to any other value, the expression is true and the statement following the if is executed. A multiway decision can be expressed as a series of elseif statements within the control block. Such a control decision block looks like this:
{if (expr)}
     templex statements1
{elseif(expr)}
     templex statements2
{elseif(expr)
     templex statements3
{else}
     templex statements4
{endif}