Syntax
argument ::= expression
Description
The data-condition statement includes the statement element in the template only if the condition is met, and omits it otherwise. If its expression evaluates to a true
value, then normal processing of the element continues, otherwise the statement element is immediately removed from the template.
If an expression evaluates to any of the next:
undefined
null
'false'
false
0
the expression evaluates to false
. Otherwise the expression evaluates to true
.
Note: extracted from Zope Page Templates Reference.
Differences with ZPT
None.
Examples
Test a variable before inserting it (the first example tests for existence and truth, while the second only tests for existence):
<p datat-condition="myObject/message" data-content="myObject/message"> Message goes here </p> <p datat-condition="exists: myObject/message" data-content="myObject/message"> Message goes here </p>
Test for alternate conditions:
<div data-repeat="item [1:10]"> <span data-replace="item-repeat/index()">1</span> is <span data-condition="item-repeat/even()">even</span> <span data-condition="item-repeat/odd()">odd</span> </div>
Test for alternate conditions in action:
Note: extracted from Zope Page Templates Reference.