Syntax
argument ::= ('structure') expression
Description
The data-replace 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 “&”, “<” to “<”, and “>” to “>”.
If the value is nothing
, then the element is simply removed. If the value is default
, then the element is left unchanged.
Note: zome parts extracted from Zope Page Templates Reference.
Differences with ZPT
- text prefix not supported but not needed, it is the default behaviour.
- This attribute can make some attributes not to work because they depend on an enclosing tag: data-repeat is one of them.
-
Because ZPT-JS modifies directly the template (ZPT generates a new document), these tags are REMOVED 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
data-replace
inside a macro definition and invoke it.
Examples
Inserting the title of a template:
<span data-replace="myObject/title">Title</span>
Inserting HTML/XML:
<div data-replace="structure table" />
Inserting nothing:
<div data-replace="nothing"> This element is a comment. </div>
Note: extracted from Zope Page Templates Reference.