An optional paragraph field is just like a normal field, except, if there is no data for that field, the entire paragraph containing the field is removed.
Field prefixes
Docmosis provides a shorthand way of changing the behaviour of a field, by applying a prefix to a field.
The prefix is typically two characters followed by either a colon or an underscore.
Later tutorials describe the different prefixes and how to define: conditional sections, repeating sections and so on.
Defining optional paragraphs
To create an optional paragraph field, add the "op:" prefix to a field as below.
This prefix changes the behaviour of the field such that, if no data is supplied for "name", or if the data is blank, the paragraph containing the field is removed and the content below moves up the page.
TIP: The optional paragraph is useful when creating address blocks to avoid blank lines when there is no data. Example Template - Offer Letter Template uses <<op:addressLine2>> to remove potential blank lines in an address block.
Removing entire paragraphs
When an optional paragraph has surrounding static content, the entire paragraph, including all content from the start of the paragraph up to and including its end marker (¶), is removed.
TIP: The optional paragraph is useful where a block content needs to be removed because there is no data needed in the context of that block. Example Template - Course Completion Letter uses <<op:awardName>> to optionally remove a sentence in a letter.
Optional paragraphs in lists
When an optional paragraph is combined with numbered or bullet lists, the list adjusts automatically if the item with the optional paragraph field is removed.
TIP: The optional paragraph is useful where fields are preceded by labels (eg: "Weight:") or followed by trailing units (eg: "KG"). In the Example Template - Bill Of Lading Template , <<op:>> is used to optionally remove the measurement units “KG” and “M³”.