From: Aaron Trevena Date: Mon, 6 Nov 2006 13:30:31 +0000 (+0000) Subject: changed template path ordering, no longer return empty paths in TT view X-Git-Tag: 2.12~25 X-Git-Url: https://git.decadent.org.uk/gitweb/?a=commitdiff_plain;h=5e09c784983b4a041e81d15e06456e0c16da5bf3;p=maypole.git changed template path ordering, no longer return empty paths in TT view git-svn-id: http://svn.maypole.perl.org/Maypole/trunk@549 48953598-375a-da11-a14b-00016c27c3ee --- diff --git a/Changes b/Changes index 5656909..3006775 100644 --- a/Changes +++ b/Changes @@ -19,6 +19,7 @@ For information about current developments and future releases, see: added CGI params to TT error template small improvements to some factory templates fix to path handling in mod_perl and CGI when location ends in / + fixed template path ordering so i.e. /tablename/list is used before /list when provided with a tablename 2.11 Mon 31 July 2006 diff --git a/lib/Maypole/View/Base.pm b/lib/Maypole/View/Base.pm index f21e771..5ae1bae 100644 --- a/lib/Maypole/View/Base.pm +++ b/lib/Maypole/View/Base.pm @@ -10,29 +10,27 @@ sub new { bless {}, shift } # By default, do nothing. sub paths { my ( $self, $r ) = @_; + warn "paths called with @_"; my $root = $r->config->template_root || $r->get_template_root; if(ref($root) ne 'ARRAY') { $root = [ $root ]; } my @output = (); foreach my $path (@$root) { - push(@output, $path); push(@output, ( $r->model_class && File::Spec->catdir( $path, $r->model_class->table ) ) ); + push(@output, $path); push(@output, File::Spec->catdir( $path, "custom" )); push(@output, File::Spec->catdir( $path, "factory" )); } - return @output; + return grep( $_, @output); } - - - sub vars { my ( $self, $r ) = @_; my $class = $r->model_class; diff --git a/lib/Maypole/View/TT.pm b/lib/Maypole/View/TT.pm index 7c30777..e4867fc 100644 --- a/lib/Maypole/View/TT.pm +++ b/lib/Maypole/View/TT.pm @@ -5,7 +5,7 @@ use Maypole::Constants; use Template; use File::Spec::Functions qw(catdir tmpdir); -our $error_template; +our $error_template; { local $/; $error_template = ; } our $VERSION = '2.11'; @@ -37,11 +37,13 @@ sub template { return OK; } else { if ($@) { - warn "fatal error in template '$template_file' : $@\n"; - $r->{error} = "fatal error in template '$template_file' : $@"; + my $error = "fatal error in template '$template_file' : $@\nTT paths : " . join(', ',$self->paths($r)) . "\n"; + $r->warn($error); + $r->{error} = $error; } else { - warn "TT error for template '$template_file'\n" . $self->{tt}->error; - $r->{error} = "TT error for template '$template_file'\n" . $self->{tt}->error; + my $error = "TT error for template '$template_file'\n" . $self->{tt}->error . "\nTT paths : " . join(', ',$self->paths($r)) . "\n"; + $r->warn($error); + $r->{error} = $error; } return ERROR; }