TracNav menu
-
Documentation
- Introduction
- Creating templates
-
Adding variables...
- 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
- Home
-
Extending patTemplate...
- Download
Working with input filters
Input filters are applied to the content of the template file before the reader analyses the tags. This enables you to modify the original HTML code and dynamically insert patTemplate tags or variables that will be interpreted by the template engine.
Using an input filter is extremely easy, you only need to pass the name of the filter to the applyInputFilter() method:
$tmpl->applyInputFilter('StripComments');
The StripComments input filter will remove all HTML and Javascript comments from the file, before it is anylyzed by patTemplate. This has two advantages:
- The reader is faster, as there is less HTML code to parse
- You can insert HTML comments between the opening <patTemplate:tmpl> and the opening <patTemplate:sub> tag. patTemplate does not allow any character data between these tags, but as the data is removed before patTemplate parses the file, it will not complain about this.
Currently patTemplate provides to input filters:
- StripComments to remove HTML and Javascript comments
- ShortModifiers to be able to use the short variable modifier syntax known from Smarty
All input filters are located in the InputFilter folder and you can easily implement new input filters.
