Template Toolkit filters are a little like Unix filters--they're little routines that take an input, transform it, and spit it back out again. And just like Unix filters, they're connected to our template output with a pipe symbol (|).
In this case, the filter we want is the oddly named format filter, which performs printf-like formatting on its input:
This fixes the case where the data is being produced by our template processor--job.description is turned into a real description, and then filtered. But we can also filter whole blocks of template content. For example, if we wanted to format the output as HTML, we could apply the html_entity filter to replace entities with their HTML encoding:
This is another example of a Template Toolkit block; we've seen FOREACH blocks and FILTER blocks. There's also the IF/ ELSIF/ELSE block:
[% IF delinquent %] Our records indicate that this is the second issuing of this invoice. Please pay IMMEDIATELY. [% ELSE %] Payment terms: <30 days. [% END %]
Other interesting filters include the upper, lower, ucfirst, and lcfirst filters to change the casing of the text; uri to URI-escape any special characters; eval to treat the text to another level of template processing, and perl_eval to treat the output as Perl, eval it, and then add the output to the template. For a more complete list of filters with examples, see the Template::Manual::Filters documentation.