Handling Curly Brackets in Text Content
In the context of a template engine that utilizes curly brackets for identifying code, special attention is needed when curly brackets are part of the intended text output. Incorrect usage can lead to errors, as the engine might interpret them as code.
Correct Usage of Curly Brackets in Text:
- Standard Use: In most scenarios, curly brackets in your templates are used to define code blocks or to enclose variables and expressions.
- Special Case - Displaying Curly Brackets in Text: If you need to include curly brackets as part of your HTML or text content within the template, simply write them twice: `{` and `}`.
{layout}
<strong>This is my text with {{curly brackets}}</strong>
{/layout}
This will correctly output:
This is my text with {curly brackets}
Why Double Brackets?
- Clarity and Avoiding Confusion: This approach makes it clear that the curly brackets are meant to be part of the text output, not code syntax.
- Preventing Errors: It helps the template engine distinguish between code and text, avoiding parsing errors or unintended behavior.
- Installation - Installing Aurora Template
- Usage - Basic Usage of the PHP NLG Template Engine
- Storage-Setting Directories for Templates and Cache
- Templates - Setting Up Input Templates
- Variables - Setting Variables in the System
- Language Constants- Setting Language Constants
- Cache - Managing Cache Creation
- Router - Standalone Mode with Routing System
- Using the PHP Template Engine
- Blocks - Block Based template engine
- Using variables - How to use variables in templates
- Calculations - Isolation and Sharing Variables
- Include and Import - include vs. import in the Template Engine
- Import - Leveraging `import{}` for Standalone Applications with a Routing System
- Resources - Adding Resources to Templates
- Control Structures - `if`, `else if`, `else`
- Ternary Operator - How to approach to ternary operator
- Macros - Macros in Template Engines - Understanding the Concept
- Custom Macros - Creating Custom Macros in Template Engines
- Forms - Creating Forms in the Template Engine
- Custom forms - Customizing Forms in the Template Engine
- Custom PHP Forms - PHP Developer's Guide to Customizing Form Templates in the Template Engine
- Curly Brackets - Handling Curly Brackets in Text Content
- Error Handling - Error Handling in PHP Template Engine
- Tests