Simple conditionals
Sometimes we want to show some HTML elements depending on a condition. This can be done using data-condition attribute. Using it the element and its content will be shown only if the condition is evaluated to true
. Let's see an example:
<p data-condition="user/isLogged()"> Logged users stuff ... </p>
ZPT-JS evaluates the user/isLogged() expression: only if it evaluated to true
the p tag will be parsed and shown. Otherwise it will not be parsed but hidden.
But... when does an expression evaluate to true
? 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
.