Skip Menu |

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

Report information
The Basics
Id: 13707
Status: resolved
Priority: 0/
Queue: Template-Extract

People
Owner: Nobody in particular
Requestors: bdfoy [...] cpan.org
Cc:
AdminCc:

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



Subject: Allow user to specify his own Template::Parser object
I ran into a problem with Template::Extract which I solved by changing the options to Template::Parser. I modified my copy of the module so I could pass my own parser into Template::Extract::Compile::compile() and Template::Extract::extract(). I'm not convinced my approach is best, but it was the shortest path to getting my work done today. :) --- Extract.pm Mon Oct 25 08:44:42 2004 +++ /usr/local/lib/perl5/site_perl/5.8.4/Template/Extract.pm Thu Jul 14 20:04:17 2005 @@ -151,10 +151,9 @@ } sub extract { - my $self = shift; - my $template = shift; - - $self->run( $self->compile($template), @_ ); + my( $self, $template, $document, $values, $parser ) = @_; + + $self->run( $self->compile($template, $parser), $document, $values ); } sub compile { --- Extract/Compile.pm Mon Oct 25 08:43:41 2004 +++ /usr/local/lib/perl5/site_perl/5.8.4/Template/Extract/Compile.pm Thu Jul 14 20:16:08 2005 @@ -53,12 +53,14 @@ } sub compile { - my ( $self, $template ) = @_; + my ( $self, $template, $parser ) = @_; + $parser = undef unless UNIVERSAL::isa( $parser, 'Template::Parser' ); + $self->_init(); if ( defined $template ) { - my $parser = Template::Parser->new( + $parser ||= Template::Parser->new( { PRE_CHOMP => 1, POST_CHOMP => 1, @@ -67,7 +69,7 @@ $parser->{FACTORY} = ref($self); $template = $$template if UNIVERSAL::isa( $template, 'SCALAR' ); - $template =~ s/\n+$//; + $template =~ s/\n+$/\n/; $template =~ s/\[%\s*(?:\.\.\.|_|__)\s*%\]/[% \/.*?\/ %]/g; $template =~ s/\[%\s*(\/.*?\/)\s*%\]/'[% "' . quotemeta($1) . '" %]'/eg;