[Dancer-users] Custom FILTERS for TemplateToolkit in dancer?

Assaf Gordon gordon at cshl.edu
Thu Oct 13 02:14:42 CEST 2011


Hello Matthew,

Matthew Vickers wrote, On 10/12/11 19:32:
> 
> I could be completely off base, and please tell me if I am, when I need to use custom code in the template I use 
> 
> before_template sub {
>     my $tokens = shift;
>     $tokens->{'my_custom_filter'} = &custom_filter;
> };

Thanks for the suggestion, but while it does add a sub to the template toolkit's namespace, it doesn't add it as a filter.

I'm looking for a way to use filters as described here:
http://search.cpan.org/~abw/Template-Toolkit-2.22/lib/Template/Manual/Directives.pod#FILTER

To be able to run template code as:
 [% VAR | my_custom_filter %]
OR
 [% FILTER my_custom_filter %]
 lots of text
 [% END %]

It seems this requires adding the filters in the template object creation step.
Didn't yet find a way to do it.


More information about the Dancer-users mailing list