5.3. New filters

Creating new filters resembles creating functions. The filter source code gets two parameters: optClass object, and the content to modify. There are three types of filters in OPT:

  1. Prefilter - processes the template source just before the compilation.
  2. Postfilter - processes the compiled template right after the compilation.
  3. Output filter - processes the template output.

The filter function name must begin with a prefix: optPrefilter, optPostfilter or optOutputfilter, depending on the filter type we want to create. It must return the modified content. Like in functions, we do not use the prefix while registering the filter.