X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FView%2FTT.pm;h=964411dc70862fcbf38756a47eebc03976cda67e;hb=3d543eda0c6f0e5ede10c93f265f9678bd31b0d5;hp=746d1c69de3d7dcb4d0d81a5fbf6139431b3c6e8;hpb=3715305fd666ffb7f7a116c2bf8854984cd0cfd0;p=catagits%2FCatalyst-View-TT.git diff --git a/lib/Catalyst/View/TT.pm b/lib/Catalyst/View/TT.pm index 746d1c6..964411d 100644 --- a/lib/Catalyst/View/TT.pm +++ b/lib/Catalyst/View/TT.pm @@ -8,8 +8,9 @@ use Data::Dump 'dump'; use Template; use Template::Timer; use MRO::Compat; +use Scalar::Util qw/blessed/; -our $VERSION = '0.32'; +our $VERSION = '0.34'; __PACKAGE__->mk_accessors('template'); __PACKAGE__->mk_accessors('include_path'); @@ -28,9 +29,10 @@ Catalyst::View::TT - Template View Class # configure in lib/MyApp.pm (Could be set from configfile instead) - MyApp->config( - name => 'MyApp', - root => MyApp->path_to('root'), + __PACKAGE__->config( + name => 'MyApp', + root => MyApp->path_to('root'), + default_view => 'TT', 'View::TT' => { # any TT configurations items go here INCLUDE_PATH => [ @@ -212,10 +214,10 @@ sub process { local $@; my $output = eval { $self->render($c, $template) }; if (my $err = $@) { - my $error = qq/Couldn't render template "$template"/; - $c->log->error($error); - $c->error($error); - return 0; + return $self->_rendering_error($c, $err); + } + if (blessed($output) && $output->isa('Template::Exception')) { + $self->_rendering_error($c, $output); } unless ( $c->response->content_type ) { @@ -227,6 +229,14 @@ sub process { return 1; } +sub _rendering_error { + my ($self, $c, $err) = @_; + my $error = qq/Couldn't render template "$err"/; + $c->log->error($error); + $c->error($error); + return 0; +} + sub render { my ($self, $c, $template, $args) = @_; @@ -247,8 +257,7 @@ sub render { die $self->template->error if $self->{render_die}; return $self->template->error; } - require Carp; - Carp::carp('The Catalyst::View::TT render() method of will die on error in a future release. If you want it to continue to return the exception instead, pass render_die => 0 to the constructor'); + $c->log->debug('The Catalyst::View::TT render() method will start dying on error in a future release. Unless you are calling the render() method manually, you probably want the new behaviour, so set render_die => 1 in config for ' . blessed($self) . '. If you wish to continue to return the exception rather than throwing it, add render_die => 0 to your config.') if $c->debug; return $self->template->error; } return $output; @@ -535,12 +544,12 @@ N.B. This is usually done automatically by L. Renders the given template and returns output. Throws a L object upon error. -The template variables are set to C<%$args> if $args is a hashref, or -$C<< $c->stash >> otherwise. In either case the variables are augmented with -C set to C< << $c->req->base >>, C to C<$c> and C to +The template variables are set to C<%$args> if C<$args> is a hashref, or +C<< $c->stash >> otherwise. In either case the variables are augmented with +C set to C<< $c->req->base >>, C to C<$c>, and C to C<< $c->config->{name} >>. Alternately, the C configuration item can be defined to specify the name of a template variable through which the -context reference (C<$c>) can be accessed. In this case, the C, C and +context reference (C<$c>) can be accessed. In this case, the C, C, and C variables are omitted. C<$template> can be anything that Template::process understands how to