[Catalyst] Using a custom TT filter

Octavian Rasnita orasnita at gmail.com
Tue May 22 11:20:46 GMT 2007


Hi,

I am trying to use a custom TT filter in a Catalyst app.

In MyApp.pm I use:

'View::TT' => {
PLUGIN_BASE => __PACKAGE__->path_to('lib'),
},

In the lib dir I have a Diverse/NoDia.pm module that looks like this:

package Diverse::NoDia;

use Template::Plugin::Filter;
use base 'Template::Plugin::Filter';

sub filter {
my ($self, $text) = @_;
$text =~ tr/ăşţîâĂŞŢÎÂ/astiaASTIA/;
return $text;
}
1;

In the template I use:

[% USE NoDia = Diverse.NoDia -%]
[% FILTER $NoDia -%]
...
[% END %]

But it gives the following error:

Couldn't render template "plugin error - Can't locate object method "load" 
via package "D:\web\TranzactiiBursiere\lib::Diverse::NoDia" (perhaps you 
forgot
to load "D:\web\TranzactiiBursiere\lib::Diverse::NoDia"?) at 
D:/usr/site/lib/Template/Plugins.pm line 215.
"

How can I define a custom TT filter in a Catalyst app?

(I need to filter a text depending on a condition, and I don't know if I can 
use another method for doing this.)

Thank you.


Octavian




More information about the Catalyst mailing list