{ignore}
Keeps PAD from reading the braces in its content as tags - for inline JavaScript, CSS, JSON and code samples.
Syntax
{ignore} ... {/ignore}
Description
Everything between {ignore} and {/ignore} is written out as it stands: the characters PAD reads as syntax - { } | = , @ - are swapped for stand-ins before the engine looks at the content, and turned back into the real characters when the page is written. Nothing inside runs: no tag, no field. A comment is the exception - comments are dropped before the template is scanned, so one inside the pair is gone too.
It is what inline code with braces needs. A <script> with an object literal, a <style> with its selector blocks, a JSON sample in a <pre> - without {ignore} each { ... } would be read as a tag, and the strict check would report it. External files are better still; the pair is for the few lines that belong in the page.
The same protection comes in two more forms. The ignore option on any tag wraps that tag's content in {ignore}: {data 'config' ignore}, {markdown ignore}. The ignore pipe escapes a value: {echo $json | ignore}. For a single brace in text, {open} and {close} are enough. {highlight} takes its content as it stands too, so a coloured code sample needs no {ignore}.
An {ignore} without its {/ignore} protects nothing; the strict check names it rather than blaming some tag inside.
Examples
Braces as text
A JavaScript sample with an object literal is written as it stands; the field inside is not read.
{ignore}
<pre>const user = { name: 'Alice', role: 'admin' };
if ( user.role == 'admin' ) { show ( '{$secret}' ); }</pre>
{/ignore}
const user = { name: 'Alice', role: 'admin' };
if ( user.role == 'admin' ) { show ( '{$secret}' ); }
An inline style block
CSS selector blocks inside the pair reach the browser; the rest of the page is rendered as usual.
{ignore}
<style>
.ignore-demo { padding: 8px 12px; border-left: 4px solid #eb6834; }
.ignore-demo b { color: #eb6834; }
</style>
{/ignore}
{set $who = 'PAD'}
<p class="ignore-demo">Styled by <b>{$who}</b>.</p>
Styled by PAD.
The option form
ignore on another tag protects that tag's content - here a data block whose rows hold braces.
{data 'snippets' ignore}
[ { "code": "{$name}" }, { "code": "{echo 1 + 1}" } ]
{/data}
<ul>
{snippets}<li><code>{$code}</code></li>{/snippets}
</ul>
-
{$name} -
{echo 1 + 1}
See also
- {open} Writes a literal opening brace that the template engine does not read as the start of a tag.
- {close} Writes a literal closing brace that the template engine does not read as the end of a tag.
- {highlight} Colours source code on the server - PAD, PHP, HTML, CSS, JavaScript, JSON, YAML, SQL or shell - with optional line numbers and marked lines.
- {markdown} Renders its content, or the value of its parameter, as Markdown and writes the HTML.