first off, many thanks for the great tool. long time user, first time I've
run into a problem.
after a recent upgrade from TT 2.14 to 2.20, I'm getting a fatal error when
I have a redundant USE for a custom filter in an included file. here's some
code that exhibits the quirk:
# ------- t1.pl - simple driver script
#!/usr/bin/perl
use Template;
my $tt = Template->new({'PLUGIN_BASE'=>'test'});
$tt->process('t1.txt',{
'name' => 'jason',
'name2' => 'fred',
'name3' => 'jim',
}) || print STDERR $tt->error();
# ------- t1.txt - simple template
[% USE simple %]
test 1: [% name | simple %]
[% INCLUDE t2.txt %]
test 3: [% name3 | simple %]
# ------- t2.txt - an included template
[% USE simple %]test 2: [% name2 | simple %]
# ------- simple.pm a super simple custom filter
package test::simple;
use Template::Plugin::Filter;
use base qw( Template::Plugin::Filter );
sub filter {
my ($self, $text, $args, $conf) = @_;
return qq|**|.$text.qq|**|;
}
sub init {
my $self = shift;
$self->{'_DYNAMIC'}=1;
my $name = $self->{ _CONFIG }->{ name } || 'simple';
$self->install_filter($name);
return $self;
}
1;
#----------
This example works fine in 2.14. In 2.20, it generates the following error:
undef error - Can't call method "filter" on an undefined value at
/usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/Template/Plugin/Filter.pm
line 74.
If I comment out the USE for simple in t2.txt it works fine. Is this a bug
or change in default behaviour?
I'd prefer to be able to keep the redundant USE. in my real world usage,
the t1 is template for an entire page, while t2 is the template for an ajax
updateable fragment of the page. so sometimes, it needs to have the USE on
its own, otherwise it just inherits from the caller.
thanks for the help and keep up the great work!
-=> jason crowther
_______________________________________________
templates mailing list
[email protected]
http://mail.template-toolkit.org/mailman/listinfo/templates