UNPKG

zpt

Version:

Zenon Page Templates - JS (ZPT-JS)

45 lines (40 loc) 1.64 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Managing errors</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 tutorial - Managing errors</h1> </div> <article data-fill-slot="'article'"> <p> Errors happen. ZPT-JS manages errors using <em>data-on-error</em> attribute. Let's see an example: </p> <strong>sample.html</strong> <pre class="brush: html"> &lt;p data-on-error="'Oh, noooo!'"&gt; ... &lt;/p&gt; </pre> <p> If an error occurs inside the <em>p</em> tag the full tag is replaced by the <em>Oh, noooo</em> string. </p> <p> The <em>data-on-error</em> attribute supports any type of expression, so you can use for example a <em>function expression</em> to invoke a function to treat the error: </p> <pre class="brush: html"> &lt;p data-on-error="errorManager()"&gt; ... &lt;/p&gt; </pre> </article> </div> </body> </html>