Jason Lewis wrote:
> I have come to the conclusion that a FILTER is what I need. I have been 
> trying to understand the documentation and examples and I am a little stuck.

Hi Jason,

You don't need to write a plugin to define your filter.  You can do it
like so:

  my $tt2 = Template->new( FILTERS => { latex => \&latex_escape } );

  sub latex_escape {
     ...etc...
  }

The benefit of writing a plugin to define your filter is so that you
can USE it from a template without having to define the FILTERS option
when you create the TT object.

However, if you subclass the Template::Plugin::Filter module, then
your filter method must be called 'filter'. 

   package MyOrg::Template::Plugin::latex_escape;
   use Template::Plugin::Filter;
   use base qw( Template::Plugin::Filter );

   sub filter {
     my $return = $_[0];
     $return =~ s/([%&\$])/\\$1/g;
     return $return;
   }

   1;

Or you can just create a regular plugin (subclass Template::Plugin) and
call the $context->define_filter() method to define one or more filters.

HTH
A


_______________________________________________
templates mailing list
[EMAIL PROTECTED]
http://lists.template-toolkit.org/mailman/listinfo/templates

Reply via email to