Index: lib/Maypole/View/TT.pm =================================================================== --- lib/Maypole/View/TT.pm (revision 309) +++ lib/Maypole/View/TT.pm (working copy) @@ -2,12 +2,34 @@ use base 'Maypole::View::Base'; use Maypole::Constants; use Template; +use File::Spec; +use strict; +our $VERSION = "1." . sprintf "%04d", q$Rev$ =~ /: (\d+)/; +our $provider; + +sub new { + my $class = shift; + my ($r) = @_; + + my $view_options = $r->config->view_options; + + $provider ||= Template::Provider->new(); + my $template = Template->new({ + COMPILE_DIR => File::Spec->tmpdir, + %$view_options, + LOAD_TEMPLATES => [ $provider ], + }); + + bless { tt => $template }, $class; +} + sub template { my ( $self, $r ) = @_; - my $template = Template->new( { INCLUDE_PATH => [ $self->paths($r) ] } ); + $provider->include_path([ $self->paths($r) ]); + my $output; - if ( $template->process( $r->template, { $self->vars($r) }, \$output ) ) { + if ($self->{tt}->process( $r->template, { $self->vars($r) }, \$output )) { $r->{output} = $output; return OK; }