Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 5. Filters > Standard Template Toolkit Filters - Pg. 179

Using Filters As we have seen, a filter is used to postprocess the text from a template. The filter acts after any other template processing on the text and transforms the text before the output phase. Example 5-1 shows the format filter being used to put HTML comment char- acters around a piece of text. Example 5-4. Using the format filter to add comments [% text = "The white zone is for loading and unloading only." %] [% FILTER format("<!-- %s -->"); text; END %] Example 5-1 generates the following output: <!-- The white zone is for loading and unloading only. --> Filters can be invoked in two different ways--either by enclosing a block of template markup between the FILTER and END directives, as in: [% FILTER html %] ... [% END %] or in side-effect notation with the FILTER coming after the item to be filtered: [% text FILTER html %]