zpt
Version:
Zenon Page Templates - JS (ZPT-JS)
86 lines (77 loc) • 4.4 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<title>ZPT-JS reference - Attributes - TALReplace</title>
<script type="text/javascript" src="../lib/zpt.min.js" defer></script>
<script type="text/javascript" src="../js/zpt.js" defer></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 - Attributes - TALReplace</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">
argument ::= ('structure') expression
</pre>
<h2 data-attributes="id 'description'">Description</h2>
<p>
The <em>data-replace</em> statement replaces an element with dynamic content. It replaces the statement element with either text or a structure (unescaped markup). The value of the expression is converted into an escaped string if you omit the prefix, and is inserted unchanged if you prefix it with structure. Escaping consists of converting “&” to “&amp;”, “<” to “&lt;”, and “>” to “&gt;”.
</p>
<p>
If the value is <code>nothing</code>, then the element is simply removed. If the value is <code>default</code>, then the element is left unchanged.
</p>
<p>
Note: zome parts extracted from <a href="https://zope.readthedocs.io/en/latest/zopebook/AppendixC.html#replace-replace-an-element">Zope Page Templates Reference</a>.
</p>
<h2 data-attributes="id 'differences'">Differences with ZPT</h2>
<ul>
<li>
<em>text</em> prefix not supported but not needed, it is the default behaviour.
</li>
<li>
This attribute can make some attributes not to work because they depend on an enclosing tag: <em>data-repeat</em> is one of them.
</li>
<li>
Because ZPT-JS modifies directly the template (ZPT generates a new document), these tags are <strong>REMOVED</strong> when they are not inside a macro definition. So if you update the dictionary a run ZPT-JS a second time these tags does not exist yet. If you need this to work place <code>data-replace</code> inside a macro definition and invoke it.
</li>
</ul>
<h2 data-attributes="id 'examples'">Examples</h2>
<p>
Inserting the title of a template:
</p>
<pre class="brush: html">
<span data-replace="myObject/title">Title</span>
</pre>
<p>
Inserting HTML/XML:
</p>
<pre class="brush: html">
<div data-replace="structure table" />
</pre>
<p>
Inserting nothing:
</p>
<pre class="brush: html">
<div data-replace="nothing">
This element is a comment.
</div>
</pre>
<p>
Note: extracted from <a href="https://zope.readthedocs.io/en/latest/zopebook/AppendixC.html#replace-replace-an-element">Zope Page Templates Reference</a>.
</p>
</article>
</div>
</body>
</html>