Subject: | Can't locate object method "plugin_use" via package "Template::Like::Processor" at (eval 11) line 2. |
Date: | Thu, 22 Nov 2007 02:35:02 -0800 (PST) |
To: | bug-Template-Like [...] rt.cpan.org |
From: | david wright <david_v_wright [...] yahoo.com> |
It is my understanding the Template::Like should be an 'almost' drop in for Template. Almost meaning, that for the TT functionality that is enabled you can use Template::Like in TT's place.
If the above statement is correct, I believe this is a bug.
The USE directive functionality of Template::Like does not seem to be working.
take this as a test case:
use Test::More tests => 4;
use strict;
use warnings;
my $tt_args = {
PLUGIN_BASE => 'Plugin',
INTERPOLATE => 1,
POST_CHOMP => 1,
DEBUG => 1,
};
BEGIN { use_ok('Template::Like') };
#BEGIN { use_ok('Template') };
BEGIN { use_ok('Plugin::Test::OurPlugin') };
use Carp qw/ confess /;
use Data::Dumper;
my $t = Template::Like->new( $tt_args );
#my $t = Template->new( $tt_args );
# prove basic functionality
{
my $output;
my $input = q{enie menie minie [% var %]};
my $replace_with = { var => 'moe' };
my $desired_result = q{enie menie minie moe};
$t->process(\$input, $replace_with, \$output);
is($desired_result, $output, 'basic template expansion');
}
# prove directive use of 'USE'
{
my $output;
my $input = q{[% USE Test.OurPlugin %][% Test.OurPlugin.return_foo() %] bar [% var %]};
my $replace_with = { var => 'baz' };
my $desired_result = q{foo bar baz};
$t->process(\$input, $replace_with, \$output);
print Dumper $output;
is($desired_result, $output, 'test USE directive');
}
cat Plugin/Test/OurPlugin.pm
package Plugin::Test::OurPlugin;
use base qw( Template::Plugin );
use Template::Plugin;
# see perldoc Template::Plugin
sub new {
my ($class, $context, @params) = @_;
bless {
_CONTEXT => $context,
}, $class;
}
sub return_foo {
return 'foo';
}
1;
perl directives.t
1..4
ok 1 - use Template::Like;
ok 2 - use Plugin::Test::OurPlugin;
{
$output.= 'enie menie minie ';
$output.= $stash->get('var');
}
ok 3 - basic template expansion
{
$self->plugin_use($stash->next($stash->get('Test'), 'OurPlugin'));
$output.= $stash->next($stash->next($stash->get('Test'), 'OurPlugin'), 'return_foo', );
$output.= ' bar ';
$output.= $stash->get('var');
}
Can't locate object method "plugin_use" via package "Template::Like::Processor" at (eval 11) line 2.
# Looks like you planned 4 tests but only ran 3.
# Looks like your test died just after 3.
If you comment out Template::Like and uncomment Template,
i.e.
#BEGIN { use_ok('Template::Like') };
BEGIN { use_ok('Template') };
#my $t = Template::Like->new( $tt_args );
my $t = Template->new( $tt_args );
The tests will pass.
Environment follows:
version Template-Like-0.05
perl -v
This is perl, v5.8.6 built for i686-linux-64int
uname -a
Linux 2.6.9-34.0.2.EL #1 Fri Jun 30 10:23:19 EDT 2006 i686
cat /etc/redhat-release
Red Hat Enterprise Linux AS release 4 (Nahant Update 3)
Thanks,
David