Using Conditional Blocks
You can use different document blocks to represent the same data depending on a condition with the help of conditional blocks. A conditional block represents a set of template options, each of which is bound with a conditional expression. At runtime, these conditional expressions are sequentially evaluated, until an expression that returns true
is reached. Then, the conditional block is replaced with the corresponding template option populated with data.
A conditional block can have a default template option that is not bound with a conditional expression. At runtime, this template option is used, when none of the conditional expressions return true
. If a default template option is missing and none of the conditional expressions return true
, then the whole conditional block is removed during runtime.
You can use the following syntax to declare a conditional block.
<<if [conditional_expression1]>>
template_option1
<<elseif [conditional_expression2]>>
template_option2
...
<<else>>
default_template_option
<</if>>
Note – A conditional expression must return a Boolean
value.
This section includes the following topics: