Else and Else-If

Category : Technical Examples

Else statements allow alternative content to be provided for an "IF" statement in case the expression is false.

Else-If statements provide an alternative expression to be used to conditionally include other content.


Template
Data Files
Output Files
All Files as a ZIP

This example explained

1) Else statements

    These may be used once within a conditional section.

    They provide an alternative option if the condition is not true.

    <<cs_trees>>option 1<<else>>option 2<<es_>> is like saying:
    IF trees= "true" THEN
      display all text from <<cs_trees>> up to <<else>>
    OTHERWISE
      display all text from <<else>> up to <<es_>>

    In your data you would have: "trees":"true" to display option 1, and "trees":"false",
    or simply omit "trees", to display option 2 (JSON example).

 
2) Else-If conditional statements

    An Else statement may also contain an expression making it an Else-If statement.

    This allows an alternative condition to be tested if the first condition is not true.

    If both the <<cs_ expression and the <<else_ expression are not true,
    no output will appear for this section in the final document.

    TRY: changing "topping" to "chocolate" or “strawberry”.

 
3) Combining Else-If and Else statements

    The expression {instruments>8} will be evaluated.

    If "true" then all following text up to the next <<else_ will appear in the final document.

    Otherwise, the expression {instruments>3} will be evaluated.

    If this expression is "true" then all the following text up to the next <<else will appear.

    If both expressions evaluate to "false" then the text from <<else to <<es_ will appear.

    In your data you would have: "instruments":"2" (JSON example).


LEARN MORE: Download our Docmosis Quick Reference [PDF].