Conditions
Conditions allow an author to create sections of content that are available in certain contexts, and excluded in others. They can be useful for the Edit/Review process, or to switch out sections meant only for print or the Web.
Syntax
Conditional text is written between two HTML Comment Tags. In the first tag, write one or more conditions between <!--condition:
and -->
. The second closing tag is always written as <!--/condition-->
. Between the tags, any valid Markdown++ content can be written. Condition names must only use alphanumeric characters, -
, and _
. Do not use spaces in Condition names.
Basics
A Condition containing a single Paragraph, using the Condition print_only
.
<!--condition:print_only-->
This paragraph is meant only for print.
<!--/condition-->
Conditions can contain multiple block-level elements.
<!--condition:print_only-->
# The Print Section
This sections is meant only for print.
It will not be visible if `print_only` is set to `Hidden`.
<!--/condition-->
Conditions can be used with inline content, too.
Go to the Section <!--condition:print_only-->on page 304<!--/condition--> for more details.
Operators
Complex logic can be used with Conditions using a set of
Operators. This block is hidden when
production
is set
Visible
using the
!
(logical NOT) operator.
<!--condition:!production-->
This paragraph is not meant for production publications.
<!--/condition-->
Multiple Conditions
Multiple Conditions can be used in a single conditional block
Operators. This example only show the block of text if
print_only
AND
production
are set to
Visible
.
<!--condition:print_only production-->
This paragraph is meant only for print and production.
<!--/condition-->
Conditions Behavior
Conditions are rendered or removed from the document when publishing based on values set in the
Conditions Window. Conditions are considered unset, and therefore always render, if they haven't been scanned into ePublisher. Conditions are also considered unset if they still have the default value
Use document condition
in the Conditions Window.
Using Conditions
First, create a condition by writing it in a source document. Below, and block of conditional text is created with the Condition print_only
.
<!--condition:print_only-->
# The Print Section
This sections is meant only for print.
It will not be visible if `print_only` is set to `Hidden`.
<!--/condition-->
Next, scan the document in ePublisher. This will add the Condition print_only
to the Conditions Window.
Once scanned, the print_only
Condition's value can be changed to either Visible
or Hidden
. The Condition is considered unset, and will always render, if the value is left with the default, Use document value
.
Condition Operators
Using Operators, an author can create additional logic to determine whether conditional text should be rendered or hidden.
In a conditional statement, the block of text renders if the entire statement evaluates to true
. The block is hidden if the statement evaluates to false
.
In this context, Visible
is considered true
, and Hidden
is considered false
. Use document value
disables the conditional statement and always renders the block.
Combine Condition names and Operators to create complex statements to determine if the content should be rendered or removed in the publication.
The Space Operator - Logical AND
The space character in a conditional statement is a Logical AND. Meaning, if the statements on both sides of
evaluate to true
, the statement passes.
The conditional text below is rendered if print_only
AND production
are set to Visible
.
<!--condition:print_only production-->
This paragraph is meant only for print and production.
<!--/condition-->
The ,
Operator - Logical OR
The ,
character in a conditional statement is a Logical OR. Meaning, if a statement on either side of ,
evaluates to true
, the statement passes.
The conditional text below is rendered if one of print_only
OR production
are set to Visible
.
<!--condition:print_only,production-->
This paragraph is meant for either print or production.
<!--/condition-->
The !
Operator - Logical NOT
The !
character in a conditional statement is a Logical NOT. Adding !
to the beginning of a Condition reverses it's truthiness. Meaning, a Condition with !
on the front of it's name evaluates Visible
to false
and Hidden
to true
.
The conditional text below is removed if production
is set to Visible
.
<!--condition:!production-->
This paragraph is not meant for production.
<!--/condition-->
Conditions and Includes
Conditions can be used as expected in
File Includes since they are processed at the same time as Includes. Additionally, Includes can be used inside of conditions to import entire documents based on certain Conditions.
Last modified date: 11/15/2024