|
home | manual | reference | regression | sequence | develop | apps |
Pages/ignore
PHP
HTML
pages/ignore.padResult <h1>Ignore - Preventing PAD from Parsing Curly Braces</h1>
<p>The {tag 'ignore'} feature tells PAD not to parse curly braces <code>{}</code> as PAD tags within specific content. This is essential when working with JavaScript, JSON data, CSS, or any content that uses curly braces for its own syntax.</p>
<h2>Why Use Ignore?</h2>
<p>PAD normally parses all <code>{}</code> pairs as potential PAD tags. When your content contains curly braces that should be treated as literal text (like JavaScript code or JSON data), you need to tell PAD to ignore them.</p>
<h2>Three Ways to Use Ignore</h2>
<h3>1. As a Tag Pair: <code>{ignore}...{/ignore}</code></h3>
<p>Wrap content in ignore tags to prevent PAD from parsing any curly braces within that block. This is commonly used for inline JavaScript or CSS.</p>
<h4>Example 1: JavaScript with Object Literals</h4>
<p>Without {tag 'ignore'}, PAD would try to parse the JavaScript object literal as PAD tags:</p>
{example 'fragments/ignore_1'}
<h4>Example 2: Inline CSS with Selector Blocks</h4>
<p>CSS uses curly braces for selector blocks. Wrap in {tag 'ignore'} to prevent PAD from parsing them:</p>
{example 'fragments/ignore_2'}
<h3>2. As a Pipe Function: <code>| ignore</code></h3>
<p>Apply ignore to the output of an expression to prevent PAD from parsing curly braces in that output. This is useful when passing JSON data to JavaScript.</p>
<h4>Example 3: JSON Data in Attributes</h4>
<p>When a variable contains JSON data, use the {tag 'ignore'} pipe function to prevent PAD from parsing the curly braces:</p>
{example 'fragments/ignore_4'}
<p>The JSON data was passed from PAD/PHP through a data attribute using <code>{echo $usersJson | ignore}</code>.</p>
<h3>3. As an Option: <code>ignore</code></h3>
<p>Add the ignore option to a tag to prevent PAD from parsing curly braces in its content.</p>
<h4>Example 4: Data Tag with JSON</h4>
<p>Use the {tag 'ignore'} option on a tag to prevent PAD from parsing curly braces in its content:</p>
{example 'fragments/ignore_5'}
<p>Without the ignore option, PAD would try to parse <code>{"theme": "dark"}</code> as PAD tags, causing errors.</p>
<h2>Best Practices</h2>
<ul>
<li><strong>Always use {tag 'ignore'} for JavaScript blocks</strong> - Any <code><script></code> tag with JavaScript should be wrapped</li>
<li><strong>Use <code>| ignore</code> for dynamic JSON</strong> - When expressions output JSON, pipe through ignore</li>
<li><strong>Keep CSS in external files</strong> - But if inline CSS is needed, wrap in {tag 'ignore'}</li>
<li><strong>Minimal scope</strong> - Only wrap what needs to be ignored, not entire templates</li>
<li><strong>Not needed for HTML</strong> - Regular HTML doesn't use curly braces, no ignore needed</li>
</ul>
<h2>What Gets Ignored?</h2>
<p>When ignore is active, PAD will NOT parse:</p>
<ul>
<li><code>{variableName}</code> - Not treated as a variable reference</li>
<li><code>{tagName}</code> - Not treated as a PAD tag</li>
<li><code>{if condition}...{/if}</code> - Not treated as conditional</li>
<li><code>{echo $expr}</code> - Not treated as expression</li>
</ul>
<p>Everything within ignored content is treated as <strong>literal text</strong>.</p>
<h2>Common Use Cases</h2>
<table border="1" cellpadding="10" cellspacing="0" style="border-collapse: collapse; width: 100%;">
<tr style="background: #f0f0f0;">
<th>Scenario</th>
<th>Method</th>
<th>Example</th>
</tr>
<tr>
<td>Inline JavaScript</td>
<td>Tag Pair</td>
<td><code>{ignore}<script>...{/ignore}</code></td>
</tr>
<tr>
<td>Inline CSS</td>
<td>Tag Pair</td>
<td><code>{ignore}<style>...{/ignore}</code></td>
</tr>
<tr>
<td>React/JSX Code</td>
<td>Tag Pair</td>
<td><code>{ignore}<script type="text/babel">...{/ignore}</code></td>
</tr>
<tr>
<td>JSON in Attributes</td>
<td>Pipe Function</td>
<td><code>data-json="{$jsonVar | ignore}"</code></td>
</tr>
<tr>
<td>JSON in Data Block</td>
<td>Option</td>
<td><code>{data 'name' ignore}</code></td>
</tr>
</table>
<h2>Important Notes</h2>
<ul>
<li><strong>Cannot nest</strong> - Once inside an ignore block, all content is literal until <code>{/ignore}</code></li>
<li><strong>Use sparingly</strong> - Only use where necessary to avoid confusion</li>
<li><strong>External files preferred</strong> - For large JavaScript or CSS, use external files instead of inline code</li>
</ul>
<h2>Summary</h2>
<table border="1" cellpadding="10" cellspacing="0" style="border-collapse: collapse; width: 100%;">
<tr style="background: #f0f0f0;">
<th>Method</th>
<th>Syntax</th>
<th>Use Case</th>
</tr>
<tr>
<td><strong>Tag Pair</strong></td>
<td><code>{ignore}...{/ignore}</code></td>
<td>Inline JavaScript, CSS, large blocks of code</td>
</tr>
<tr>
<td><strong>Pipe Function</strong></td>
<td><code>{expression | ignore}</code></td>
<td>Expression output contains JSON or curly braces</td>
</tr>
<tr>
<td><strong>Option</strong></td>
<td><code>{tag ignore}</code></td>
<td>Tag content should not be parsed</td>
</tr>
</table>
<h2>See Also</h2>
<ul>
<li>{tag 'open'} - Output opening brace <code>{</code></li>
<li>{tag 'close'} - Output closing brace <code>}</code></li>
<li>{tag 'echo'} - Evaluate expressions</li>
<li>{tag 'data'} - Define inline data</li>
</ul>Ignore - Preventing PAD from Parsing Curly Braces
The {ignore} feature tells PAD not to parse curly braces
{}as PAD tags within specific content. This is essential when working with JavaScript, JSON data, CSS, or any content that uses curly braces for its own syntax.Why Use Ignore?
PAD normally parses all
{}pairs as potential PAD tags. When your content contains curly braces that should be treated as literal text (like JavaScript code or JSON data), you need to tell PAD to ignore them.Three Ways to Use Ignore
1. As a Tag Pair:
{ignore}...{/ignore}Wrap content in ignore tags to prevent PAD from parsing any curly braces within that block. This is commonly used for inline JavaScript or CSS.
Example 1: JavaScript with Object Literals
Without {ignore}, PAD would try to parse the JavaScript object literal as PAD tags:
PHP
HTML
Result Example 2: Inline CSS with Selector Blocks
CSS uses curly braces for selector blocks. Wrap in {ignore} to prevent PAD from parsing them:
PHP
HTML
Result 2. As a Pipe Function:
| ignoreApply ignore to the output of an expression to prevent PAD from parsing curly braces in that output. This is useful when passing JSON data to JavaScript.
Example 3: JSON Data in Attributes
When a variable contains JSON data, use the {ignore} pipe function to prevent PAD from parsing the curly braces:
PHP
HTML
Result The JSON data was passed from PAD/PHP through a data attribute using
{echo $usersJson | ignore}.3. As an Option:
ignoreAdd the ignore option to a tag to prevent PAD from parsing curly braces in its content.
Example 4: Data Tag with JSON
Use the {ignore} option on a tag to prevent PAD from parsing curly braces in its content:
PHP
HTML
Result Without the ignore option, PAD would try to parse
{"theme": "dark"}as PAD tags, causing errors.Best Practices
- Always use {ignore} for JavaScript blocks - Any
<script>tag with JavaScript should be wrapped- Use
| ignorefor dynamic JSON - When expressions output JSON, pipe through ignore- Keep CSS in external files - But if inline CSS is needed, wrap in {ignore}
- Minimal scope - Only wrap what needs to be ignored, not entire templates
- Not needed for HTML - Regular HTML doesn't use curly braces, no ignore needed
What Gets Ignored?
When ignore is active, PAD will NOT parse:
{variableName}- Not treated as a variable reference{tagName}- Not treated as a PAD tag{if condition}...{/if}- Not treated as conditional{echo $expr}- Not treated as expressionEverything within ignored content is treated as literal text.
Common Use Cases
Scenario Method Example Inline JavaScript Tag Pair {ignore}<script>...{/ignore}Inline CSS Tag Pair {ignore}<style>...{/ignore}React/JSX Code Tag Pair {ignore}<script type="text/babel">...{/ignore}JSON in Attributes Pipe Function data-json="{$jsonVar | ignore}"JSON in Data Block Option {data 'name' ignore}Important Notes
- Cannot nest - Once inside an ignore block, all content is literal until
{/ignore}- Use sparingly - Only use where necessary to avoid confusion
- External files preferred - For large JavaScript or CSS, use external files instead of inline code
Summary
Method Syntax Use Case Tag Pair {ignore}...{/ignore}Inline JavaScript, CSS, large blocks of code Pipe Function {expression | ignore}Expression output contains JSON or curly braces Option {tag ignore}Tag content should not be parsed See Also
- {open} - Output opening brace
{- {close} - Output closing brace
}- {echo} - Evaluate expressions
- {data} - Define inline data
|
home | manual | reference | regression | sequence | develop | apps |
(c) 2003-2025 Herbert Groot Jebbink