X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=lib%2FMaypole%2FView%2FTT.pm;h=5778d8b734b22b0d78c940ef7007400f1fc85c89;hb=3ed98309a0852fc198f9e4d0e6f70c5510c8282f;hp=7a2ab0307501e6da5fe6281b2c17ece946966b37;hpb=7249c53d755f2eb5b8b5bb471ff49b8dd6f3dbf0;p=maypole.git diff --git a/lib/Maypole/View/TT.pm b/lib/Maypole/View/TT.pm index 7a2ab03..5778d8b 100644 --- a/lib/Maypole/View/TT.pm +++ b/lib/Maypole/View/TT.pm @@ -12,7 +12,6 @@ our $VERSION = 2.11; sub template { my ( $self, $r ) = @_; - unless ($self->{tt}) { my $view_options = $r->config->view_options || {}; $self->{provider} = Template::Provider->new($view_options); @@ -25,16 +24,24 @@ sub template { $self->{provider}->include_path([ $self->paths($r) ]); my $template_file = $r->template; + my $ext = $r->config->template_extension; $template_file .= $ext if defined $ext; my $output; - if ($self->{tt}->process($template_file, { $self->vars($r) }, \$output )) { - $r->{output} = $output; - return OK; + my $processed_ok = eval{$self->{tt}->process($template_file, { $self->vars($r) }, \$output );}; + if ($processed_ok) { + $r->{output} = $output; + return OK; } else { + if ($@) { + warn "fatal error in template '$template_file' : $@\n"; + $r->{error} = "fatal error in template '$template_file' : $@"; + } else { + warn "TT error for template '$template_file'\n" . $self->{tt}->error; $r->{error} = "TT error for template '$template_file'\n" . $self->{tt}->error; - return ERROR; + } + return ERROR; } }