TracNav menu
- Home
-
Documentation
- Introduction
- Creating templates
-
Adding variables
- Default values
- Accessing variables from other templates
- Using the simpleCondition template
- Creating conditional templates
- Creating alternating rows?
-
Advanced features
- Reading templates from different data sources
- Variable Modifiers
- Improving performance with template caches
- Output Filters
- Input Filters
- Tag Reference
- FAQ
-
Extending patTemplate
- Variable Modifiers
- Template Readers
- Output Filters
- Input Filters
- Custom Tags
- Template Cache
- Template Dumpers
- Download
Adding comments to templates
If your templates get more complex, you might want to document what you are doing, so it is easier for other developers or designers to comprehend the template structure. Of course you could just add simple HTML-comments to the templates, but these would be sent to the browser when displaying the page, which would result in additional traffic, although the information is not needed by the client.
To avoid this, patTemplate provides the <patTemplate:comment/> tag. All data inside this tag will be ignored when the page is displayed:
<patTemplate:tmpl name="page">
<patTemplate:comment>
You may place any content here, that documents the page template.
</patTemplate:comment>
Content of the template goes here...
</patTemplate:tmpl>
When reading and displaying this template, the result will be:
Content of the template goes here...
Using the comment tag has another advantage. Although the data inside the comment tags will not be displayed, patTemplate will read and interpret it. When debugging your templates? with the dump() method, the comments will be displayed next to the templates, that contained them.
