Hello,

In your TT::View you could add:

use base 'Catalyst::View::TT';

sub noDia {
    my $text = shift;
    $text =~ tr/ăşţîâĂŞŢÎÂ/astiaASTIA/;
    return $text;
}

__PACKAGE__->config({
    FILTERS => {
        'noDia' => \&noDia,
    },
});

So, in your template you should be able to use:

[% FILTER noDia -%]
data to parse
[% END %]


I hope this helps. This is just form my knowledge of TT. I'm still getting used to Catalyst so someone else might have a better idea but its worth a try ;)

Adeola


On 22 May 2007, at 11:20, Octavian Rasnita wrote:

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


_______________________________________________
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/ catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/

--
Creative Developer - Digital Craftsmen Ltd
Exmouth House, 3 Pine Street
London, EC1R 0JH
t: +44 20 7183 1410
f: +44 20 7099 5140
m: +44 79 3952 0786
w: http://www.digitalcraftsmen.net/





_______________________________________________
List: Catalyst@lists.rawmode.org
Listinfo: http://lists.rawmode.org/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@lists.rawmode.org/
Dev site: http://dev.catalyst.perl.org/

Reply via email to