Subject: | Patch to pass parameters to the TT2 renderer |
The attached patch fixes a very minor bug ('render' called 'renderer' instead of using '$self->{renderer}'), and adds the ability to pass parameters to the Template constructor. I use this to pass 'RELATIVE=>1' and factor my templates (e.g. the licensing terms have to be included in the README and in every .pm file, so I put them in a common template).
Hope this is useful.
--- .cpanplus/5.8.6/build/Module-Starter-Plugin-TT2-0.12/lib/Module/Starter/Plugin/TT2.pm 2004-10-20 04:55:27.000000000 +0200
+++ Library/Perl/Module/Starter/Plugin/TT2.pm 2005-09-15 16:12:24.000000000 +0200
@@ -72,7 +72,11 @@
=cut
-sub renderer { my $renderer = Template->new; }
+sub renderer {
+ my ($self) = @_;
+ my $conf = (eval $self->{template_parms})||{};
+ my $renderer = Template->new($conf);
+}
=head2 C<< render( $template, \%options ) >>
@@ -90,7 +94,7 @@
$options->{self} = $self;
$options->{year} = $self->_thisyear;
- $self->renderer->process(\$template, $options, \$output);
+ $self->{renderer}->process(\$template, $options, \$output);
return $output;
}