# config file:
engines:
template_toolkit:
PLUGIN_BASE: 'Template::Plugin'
# The filter code:
package Template::Plugin::FilterFence;
use Template::Plugin::Filter;
use base qw( Template::Plugin::Filter );
sub filter {
my ($self, $text) = @_;
return join ' ' # etc
}
1;
# The template that uses the filter:
<% USE FilterFence %>
<% FOREACH row IN rows %>
| <% row.0 %> | <% row.1 | $FilterFence %>
<% END %>
|
####
use Test::More;
use Template::Plugin::FilterFence;
my $t = 'Template::Plugin::FilterFence'->new;
is($t->filter(0), q(), 'zero');
is($t->filter(1), '|', 'one');
# etc.
####
sub init {
my $self = shift;
$self->install_filter('fence');
return $self
}
####
<% row.1 | fence %>
####
Can't call method "define_filter" on an undefined value at .../Template/Plugin/Filter.pm line 117.
####
my $t = bless {}, 'Template::Plugin::FilterFence';
####
undef *Template::Plugin::FilterFence::init;