Skip Menu |

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

Report information
The Basics
Id: 29928
Status: resolved
Priority: 0/
Queue: Text-Template

People
Owner: Nobody in particular
Requestors: tmurray.NO [...] MEAT.wumpus-cave.net
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.44
Fixed in: 1.48



Subject: Precompiled Templates Don't Work with Preprocessing
When using precompiled templates, the preprocessor sub receives the template data in the form of arrayrefs. However, after the preprocessor sub is called, Text::Template::Preprocess::fill_in() calls set_source_data(), which sets $self->{TYPE} to 'STRING'. This results in output like 'ARRAY(0x2a50cb0)'. The patch adds a new argument to Text::Template::set_source_data() which specifies the type of the data (defaults to 'STRING' to maintain backwards compatibility). Text::Template::Preprocess::fill_in() makes sure the type before and after preprocessing will stay the same.
Subject: Text-Template-1.44.patch
diff -ru Text-Template-1.44/lib/Text/Template/Preprocess.pm Text-Template-1.44-patched/lib/Text/Template/Preprocess.pm --- Text-Template-1.44/lib/Text/Template/Preprocess.pm 2003-04-29 16:02:09.000000000 -0400 +++ Text-Template-1.44-patched/lib/Text/Template/Preprocess.pm 2007-10-11 11:52:22.000000000 -0400 @@ -10,10 +10,11 @@ my $pp = $args{PREPROCESSOR} || $self->{PREPROCESSOR} ; if ($pp) { local $_ = $self->source(); + my $type = $self->{TYPE}; # print "# fill_in: before <$_>\n"; &$pp; # print "# fill_in: after <$_>\n"; - $self->set_source_data($_); + $self->set_source_data($_, $type); } $self->SUPER::fill_in(@_); } diff -ru Text-Template-1.44/lib/Text/Template.pm Text-Template-1.44-patched/lib/Text/Template.pm --- Text-Template-1.44/lib/Text/Template.pm 2003-04-29 16:24:30.000000000 -0400 +++ Text-Template-1.44-patched/lib/Text/Template.pm 2007-10-11 11:51:15.000000000 -0400 @@ -130,10 +130,10 @@ } sub set_source_data { - my ($self, $newdata) = @_; + my ($self, $newdata, $type) = @_; $self->{SOURCE} = $newdata; $self->{DATA_ACQUIRED} = 1; - $self->{TYPE} = 'STRING'; + $self->{TYPE} = $type || 'STRING'; 1; }
This has been committed and will be in v1.48 -- Regards, Michael Schout