Conditional Sections (Part 1)

You can use the conditional section <<cs_ directive in a template to include or exclude a section of content. This is similar to using an "IF" statement.

If you use a conditional section within a numbered list, the numbering adjusts automatically.

This example in detail

This example uses a conditional section on its own, and also within a numbered list, and examples of conditional sections using expressions.

Conditional sections

These start with the <<cs_ condtional section directive and end with <<es_.

These are like IF statements. <<cs_sampleValue1>> is like saying:

IF sampleValue1= "true" THEN

display all text up to <<es_sampleValue1>>

The data contains "sampleValue1":"true" (JSON example).

If <<cs_ or <<es_ is on a line by itself the 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 in the list 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 return 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.

Feedback

Invalid Input

Sorry, this field will only accept letters and numbers, and not special characters, to limit spam. Please also consider contacting support@docmosis.com if you need help with this article.

Sorry, this field will only accept letters and numbers, and not special characters, to limit spam.

Invalid Input