UNPKG

zpt

Version:

Zenon Page Templates - JS (ZPT-JS)

60 lines (53 loc) 2.82 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>ZPT-JS reference - Exists expressions</title> <script type="module" src="../js/zpt.js"></script> <script type="text/javascript" src="../lib/syntaxHighlighter/lib.js"></script> <link rel="stylesheet" type="text/css" href="../docs.css"> <link rel="stylesheet" type="text/css" href="../lib/syntaxHighlighter/theme.css"> </head> <body> <div data-use-macro="'page@templates.html'"> <div data-fill-slot="'page-header'"> <h1>ZPT-JS reference - Exists expressions</h1> <ul> <li><a href="#syntax">Syntax</a>.</li> <li><a href="#description">Description</a>.</li> <li><a href="#differences">Differences with ZPT</a>.</li> <li><a href="#examples">Examples</a>.</li> </ul> </div> <article data-fill-slot="'article'"> <h2 data-attributes="id 'syntax'">Syntax</h2> <pre class="syntax"> exists_expression ::= 'exists:' expression </pre> <h2 data-attributes="id 'description'">Description</h2> <p> <em>Exists</em> expressions test for the existence of paths. An exists expression returns <code>true</code> when the path expressions following its expression returns a value and it is not <code>undefined</code>. It is <code>false</code> when the path expression cannot locate an object or if it evaluates to <code>undefined</code>. </p> <p> Note: some parts extracted from <a href="https://zope.readthedocs.io/en/latest/zopebook/AppendixC.html#tales-exists-expressions">Zope Page Templates Reference</a>. </p> <h2 data-attributes="id 'differences'">Differences with ZPT</h2> <p> In ZPT if an expression evaluates to <code>undefined</code> exists returns <code>true</code>; ZPT-JS returns <code>false</code>. </p> <h2 data-attributes="id 'examples'">Examples</h2> <p> Testing for the existence of a property in an object: </p> <pre class="brush: html"> &lt;div data-condition="not: exists: myObject/name"&gt; Name not set! &lt;/div&gt; </pre> <p> Note: some parts extracted from <a href="https://zope.readthedocs.io/en/latest/zopebook/AppendixC.html#tales-exists-expressions">Zope Page Templates Reference</a>. </p> </article> </div> </body> </html>