Skip Menu |

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

Report information
The Basics
Id: 13225
Status: resolved
Priority: 0/
Queue: Template-Timer

People
Owner: Nobody in particular
Requestors: dave [...] gnofn.org
Cc:
AdminCc:

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



Subject: Problem with eval'ed blocks
Distribution: Template-Timer-0.02 Perl version: 5.6.1 OS: FreeBSD 4.5 This module does a great job with templates stored in files. However, if it encouters a template in a string that's being rendered via the eval filter, it chokes. Attached is a patch that will allow it to handle these eval'ed blocks. Here's a failing test (eval.t): use Test::More tests => 1; use Template::Timer; my $tt = Template->new( { CONTEXT => Template::Timer->new } ); my $block = "[% thing = 'doohickey' %]"; ok( $tt->process( \*DATA, { block => $block } ), 'eval' ); __DATA__ [% block | eval %] [% thing %]
--- blib/lib/Template/Timer.pm.orig Tue Oct 26 11:10:10 2004 +++ blib/lib/Template/Timer.pm Mon Jun 13 10:13:17 2005 @@ -2,6 +2,7 @@ use warnings; use strict; +require UNIVERSAL; =head1 NAME @@ -23,6 +24,8 @@ Using Template::Timer is simple. + use Template::Timer; + my %config = ( # Whatever your config is INCLUDE_PATH => "/my/template/path", COMPILE_EXT => ".ttc", @@ -63,7 +66,11 @@ my $super = __PACKAGE__->can("SUPER::$sub") or die; *$sub = sub { my $self = shift; - my $template = ref $_[0] ? $_[0]->name : $_[0]; + my $template = $_[0]; + if ( ref $_[0] ) { + $template = $_[0]->name if UNIVERSAL::isa( $_[0], 'Template::Document' ); + $template = '(evaluated block)' if ref $_[0] eq 'SCALAR'; + } my $start = [Time::HiRes::gettimeofday]; my $data = $super->($self, @_); my $elapsed = Time::HiRes::tv_interval($start);
I've added t/eval.t to Version 0.04, but haven't fixed it.
On Sun Oct 16 23:55:40 2005, andy@petdance.com wrote: Show quoted text
> I've added t/eval.t to Version 0.04, but haven't fixed it.
5 years great track record. I'm too lazy to give you a patch. but you should be able to translate this into your current code base. my $template # get the template filename # conditional # set $template to = ref($what) eq 'ARRAY' ? join( ' + ', @{$what} ) : ref($what) eq 'SCALAR' ? '(evaluated block)' : ref($what) ? $what->name : $what ; fixed in Template::ShowStartStop commit 0e48fbd7d432b3356d9758a2390aaa6aff7f33a1 will be in version 0.09
Show quoted text
> 5 years great track record.
I wonder why you would say that.
Fixed by #58523.