|
home | manual | reference | regression | sequence | develop | apps |
Ignore
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
Basic Concepts
Advanced concepts
Constructs
Miscellaneous
|
home | manual | reference | regression | sequence | develop | apps |
(c) 2003-2025 Herbert Groot Jebbink