Skip Menu |

This queue is for tickets about the Template-Like CPAN distribution.

Report information
The Basics
Id: 30911
Status: resolved
Worked: 6 hours (360 min)
Priority: 0/
Queue: Template-Like

People
Owner: s.aska.org [...] gmail.com
Requestors: david_v_wright [...] yahoo.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



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
From: david_v_wright [...] yahoo.com
On Thu Nov 22 05:37:26 2007, david_v_wright@yahoo.com wrote: Show quoted text
> 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 > >
Hello, I am submitting a patch (and associated files) to enable the functionality I filed a bug against. Included is a test demonstrating the added functionality. Here is a sample from t/directives.t: (the newly added test) { my $output; my $input = q{[% USE OurPlugin %][% OurPlugin.return_foo() %]}; my $replace_with = {}; my $desired_result = q{foo}; $t->process(\$input, $replace_with, \$output); is($output, $desired_result, q{basic test 'USE' directive}); } { my $output; my $input = q{[% USE OurPlugin %][% OurPlugin.substitute_with_raz( var ) %]}; my $replace_with = { var => ' baz' }; my $desired_result = q{raz}; $t->process(\$input, $replace_with, \$output); is($output, $desired_result, q{test 'USE' directive with 1 param as arg}); } { my $output; my $input = q{[% USE OurPlugin %][% OurPlugin.substitute_arg1_with_arg2( var, 'foo') %]}; my $replace_with = { var => 'glue' }; my $desired_result = q{foo}; $t->process(\$input, $replace_with, \$output); is($output, $desired_result, q{test 'USE' directive with 2 param args}); } { my $output; my $input = q{[% USE OurPlugin; OurPlugin.return_foo(); var %]}; my $replace_with = { var => ' baz' }; my $desired_result = q{foo baz}; $t->process(\$input, $replace_with, \$output); is($desired_result, $output, q{test USE directive with code delimiter of ';' }); } Here's how to apply the patch dwright % : cd ~/12_15_07/Template-Like-0.05 dwright % :Template-Like-0.05% patch -p0 < Processor.pm.patch patching file lib/Template/Like/Processor.pm dwright %:Template-Like-0.05% patch -p0 < Stash.pm.patch patching file lib/Template/Like/Stash.pm Here are the included files. dwright 12_15_07 % tar czvf Template-Like-0.05.tar.gz Template-Like-0.05 Template-Like-0.05/ Template-Like-0.05/lib/ Template-Like-0.05/lib/Template/ Template-Like-0.05/lib/Template/Like/ Template-Like-0.05/lib/Template/Like/Processor.pm Template-Like-0.05/lib/Template/Like/Stash.pm Template-Like-0.05/t/ Template-Like-0.05/t/Plugin/ Template-Like-0.05/t/Plugin/Test/ Template-Like-0.05/t/Plugin/Test/OurPlugin.pm Template-Like-0.05/t/directives.t Template-Like-0.05/Processor.pm.patch Template-Like-0.05/Stash.pm.patch tested on linux 2.6.9-34.0.2.EL i686 I believe I have maintained the coding style currently in use by this module. Feel free to contact me with any questions. Thank you, David
Download Template-Like-0.05.tar.gz
application/x-gzip 8.2k

Message body not shown because it is not plain text.

I would appreciate your kind cooperation. I learned a lot from what I heard. It supported a semicolon. Thank you very much. I am sorry that correspondence is late. Thank you, Aska On Sat Nov 15 20:40:00 2007, david_v_wright@yahoo.com wrote: Show quoted text
> On Thu Nov 22 05:37:26 2007, david_v_wright@yahoo.com wrote:
> > 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 > > > >
> > Hello, > > I am submitting a patch (and associated files) to enable the > functionality I filed a bug against. > > Included is a test demonstrating the added functionality. > > Here is a sample from t/directives.t: (the newly added test) > > { > my $output; > my $input = q{[% USE OurPlugin %][% OurPlugin.return_foo() %]}; > my $replace_with = {}; > my $desired_result = q{foo}; > $t->process(\$input, $replace_with, \$output); > is($output, $desired_result, q{basic test 'USE' directive}); > } > > { > my $output; > my $input = q{[% USE OurPlugin %][% > OurPlugin.substitute_with_raz( var ) %]}; > my $replace_with = { var => ' baz' }; > my $desired_result = q{raz}; > $t->process(\$input, $replace_with, \$output); > is($output, $desired_result, q{test 'USE' directive with 1 param as
arg}); Show quoted text
> } > > { > my $output; > my $input = q{[% USE OurPlugin %][% > OurPlugin.substitute_arg1_with_arg2( var, 'foo') %]}; > my $replace_with = { var => 'glue' }; > my $desired_result = q{foo}; > $t->process(\$input, $replace_with, \$output); > is($output, $desired_result, q{test 'USE' directive with 2 param args}); > } > > { > my $output; > my $input = q{[% USE OurPlugin; OurPlugin.return_foo(); var
%]}; Show quoted text
> my $replace_with = { var => ' baz' }; > my $desired_result = q{foo baz}; > $t->process(\$input, $replace_with, \$output); > is($desired_result, $output, q{test USE directive with code delimiter > of ';' }); > } > > > Here's how to apply the patch > dwright % : cd ~/12_15_07/Template-Like-0.05 > dwright % :Template-Like-0.05% patch -p0 < Processor.pm.patch > patching file lib/Template/Like/Processor.pm > dwright %:Template-Like-0.05% patch -p0 < Stash.pm.patch > patching file lib/Template/Like/Stash.pm > > Here are the included files. > dwright 12_15_07 % tar czvf Template-Like-0.05.tar.gz Template-Like-0.05 > Template-Like-0.05/ > Template-Like-0.05/lib/ > Template-Like-0.05/lib/Template/ > Template-Like-0.05/lib/Template/Like/ > Template-Like-0.05/lib/Template/Like/Processor.pm > Template-Like-0.05/lib/Template/Like/Stash.pm > Template-Like-0.05/t/ > Template-Like-0.05/t/Plugin/ > Template-Like-0.05/t/Plugin/Test/ > Template-Like-0.05/t/Plugin/Test/OurPlugin.pm > Template-Like-0.05/t/directives.t > Template-Like-0.05/Processor.pm.patch > Template-Like-0.05/Stash.pm.patch > > tested on linux 2.6.9-34.0.2.EL i686 > > I believe I have maintained the coding style currently in use by this > module. > > Feel free to contact me with any questions. > > Thank you, > David > > >