---
title: "Conditionally add/remove content"
description: "Add or remove content conditionally in Docmosis templates so generated documents display only relevant sections by evaluating true/false expressions"
canonical_url: "https://resources.docmosis.com/template-tutorials/conditional-sections"
last_reviewed: 2026-06-12
---
# Conditionally add/remove content
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 section.
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](/template-tutorials/expressions-logic) and [Expressions - Math](/template-tutorials/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.
## Conditionally add/remove content - related json data
```json
{
"sampleValue1": "true",
"sampleValue2": "false",
"sampleValue3": "7",
"sampleValue4": "frog"
}
```
## Conditionally add/remove content - example template syntax
# Conditional Sections
<<cs_ starts a conditional section
<<es_ ends a section
<<cs_sampleValue1>>
This line only appears in the final document if **sampleValue1** is set to **“true”**.
<<es_sampleValue1>>
The numbering of items in the list adjusts automatically:
1. RED
<<cs_sampleValue2>>
1. YELLOW
<<es_sampleValue2>>
1. GREEN
2. BLUE
Any expression that returns a true/false value can be used when creating conditional sections
<<cs_{sampleValue3=7}>>
This line only appears in the final document if **sampleValue3** is equal to the number **7**.
<<es_>>
<<cs_{sampleValue4=’frog’}>>
This line only appears in the final document if **sampleValue4** is equal to the number **frog**.
<<es_>>
<<cs_{sampleValue1||sampleValue2}>>
This line only appears in the final document if **sampleValue1 or sampleValue2** is **True**.
<<es_>>