You are here: WikiStart/Docs/Advanced/InputFilters


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:

  1. The reader is faster, as there is less HTML code to parse
  2. 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.