UNPKG

zpt

Version:

Zenon Page Templates - JS (ZPT-JS)

90 lines (80 loc) 4.05 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>ZPT-JS reference - Attributes - METALUseMacro</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 - Attributes - METALUseMacro</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 ::= expression </pre> <h2 data-attributes="id 'description'">Description</h2> <p> The <em>data-use-macro</em> statement replaces the statement element with a macro. The statement expression describes a macro definition. </p> <p> In ZPT-JS the expression will generally be a path expression referring to a macro defined in another template. See <a href="attributes-METALDefineMacro.html">data-define-macro</a> for more information. </p> <p> The effect of expanding a macro is to graft a subtree from another document (or from elsewhere in the current document) in place of the statement element, replacing the existing sub-tree. Parts of the original subtree may remain, grafted onto the new subtree, if the macro has slots. See <a href="attributes-METALDEfineSlot.html">data-define-slot</a> for more information. </p> <p> Note: some parts extracted from <a href="https://zope.readthedocs.io/en/latest/zopebook/AppendixC.html#define-macro-define-a-macro">Zope Page Templates Reference</a>. </p> <h2 data-attributes="id 'differences'">Differences with ZPT</h2> <ul> <li> In ZPT the syntax is <em>argument ::= Name</em>, so all invokations are literals. ZPT-JS uses expressions. </li> <li> Syntax of external macro invokation. </li> <li> There is no Zope tree in which to locate templates. </li> </ul> <h2 data-attributes="id 'examples'">Examples</h2> <p> Invokation of <em>copyright</em> macro in the same file (internal macro invokation): </p> <pre class="brush: html"> &lt;p data-use-macro="'copyright'"&gt; Macro goes here &lt;/p&gt; </pre> <p> Invokation of <em>copyright</em> macro in <em>macros.html</em> file (external macro invokation): </p> <pre class="brush: html"> &lt;p data-use-macro="'copyright@macros.html'"&gt; Macro goes here &lt;/p&gt; </pre> <p> Invokation of macro defined by <em>macroPath</em> variable (it can be an internal or external macro invokation): </p> <pre class="brush: html"> &lt;p data-use-macro="macroPath"&gt; Macro goes here &lt;/p&gt; </pre> </article> </div> </body> </html>