Conditional Sections 2
Category : Technical Examples
Conditional Sections covered how to add or remove content from the final document.
When a conditional section returns false and content is removed, there is sometimes a blank line left behind.
Blank lines can be controlled by changing the way you lay out the conditional sections in your templates.
This example explained
Important: To understand these examples, turn on the hidden characters within your editor to reveal where the paragraph markers ¶ are located in your template.
Controlling the appearance of blank lines
The examples below use conditions sections that will always evaluate as either true or false – but they could equally be <<cs_ statements that are controlled by data.
The first example illustrates a single line version of a conditional section.
Because <<cs_true>> returns true, the relevant text will appear.
The <<cs_false>> returns false, and a blank line remains even though the text is removed.
When the <<cs_ and <<es_ fields are on the same line, Docmosis will include or remove everything between the fields.
Because the paragraph marker is outside the fields, it will always remain in the final document which causes the blank line.
This three line version leaves no blank line when the conditional statement returns false.
When a <<cs_ or <<es_ appears on a line of its own – Docmosis will completely remove the line including the trailing paragraph marker.
The relevant line, between the <<cs_ and <<es_, is on its own line. Docmosis will include or remove everything between the fields.
Because the paragraph marker is between the fields, it will also be included or removed.
Using Conditional Sections in Numbered/Bulleted Lists
This example reinforces the need to place <<cs_ and <<es_ on lines of their own when used within either bulleted or numbered lists.
The <<cs_ and <<es_ should not be part of the list itself.
To avoid unwanted blank lines:
1. Make sure the <<cs_ and <<es_ are on lines of their own ending in paragraph markers.
There should be no trailing spaces after the paragrah markers.
2. Keep conditional text on separate lines as “paragraphs” ending in paragraph markers.
Do not use line breaks at the end of the text.
LEARN MORE: Download our Docmosis Quick Reference [PDF].