Conditional sections are similar to an "IF" statement.
They are created using the <<cs_ prefix, and are used to mark content that should be included or removed from the generated document.
If you use a conditional section within a numbered list, the numbering adjusts automatically.
Conditional sections
Conditional sections start with the <<cs_ field prefix and end with a <<es_.
The statement <<cs_sampleValue1>> is like saying:
IF sampleValue1= "true" THEN
display all text up to the closing field <<es_sampleValue1>>
The data should contain a true/false boolean value. In JSON this could be something like:
- "sampleValue1":"true"
- "sampleValue1":true
TIP: If a<<cs_ or <<es_ field appears on a line by itself the entire line is removed in the final document.
Used in a numbered list
The numbered list in the example has the second item surrounded by <<cs_ and <<es_.
The data contains: "sampleValue2":"false" (JSON example).
In the final document item 2 does not appear.
The numbering of the remaining items adjusts automatically.
Note: it is important that the <<cs_ and <<es_ appear on lines by themselves and that they are not part of the list.
Using expressions in a conditional section
Any expression that returns a true or false value can be used in a conditional sections.
Expressions allow you to perform multiple tests to determine if content should be added or removed. For a more detailed discussion on expressions please see the articles on Expressions - Logic and Expressions - Math.
Example 1 :
In the example template, the expression {sampleValue3=7} is evaluated and will return a value of either true or false. If "true" then all following text up to the next <<es_ appears in the final document.
The data contains "sampleValue3":"7" (JSON example), so in this case the text is displayed.
Example 2:
The expression {sampleValue4=’frog’} is evaluated and will return a true or false value. If "true" then all following text up to the next <<es_ appears in the final document.
The data contains "sampleValue4":"frog" (JSON example), so in this case the text is displayed.
Example 3:
The expression {sampleValue1||sampleValue2} is evaluated. If either sampleValue1 or sampleValue2 is "true" then all following text up to the next <<es_ appears in the final document.
The data contains "sampleValue1":"true" and "sampleValue2":"false"(JSON example), so in this case the text is displayed.