X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FView%2FTT.pm;h=f545ea434ff6fc397c655130e79d13ed508c6d84;hb=ee06e29a8475f5dd926aa81c6fcce4f75b7d7585;hp=da9a3f03f02b079bb86b448616df0510fb3df237;hpb=e4739bcf141393ba31a9ac68a5ba005865b4496b;p=catagits%2FCatalyst-View-TT.git diff --git a/lib/Catalyst/View/TT.pm b/lib/Catalyst/View/TT.pm index da9a3f0..f545ea4 100644 --- a/lib/Catalyst/View/TT.pm +++ b/lib/Catalyst/View/TT.pm @@ -10,12 +10,13 @@ use Template::Timer; use MRO::Compat; use Scalar::Util qw/blessed weaken/; -our $VERSION = '0.39'; +our $VERSION = '0.41'; $VERSION = eval $VERSION; __PACKAGE__->mk_accessors('template'); __PACKAGE__->mk_accessors('expose_methods'); __PACKAGE__->mk_accessors('include_path'); +__PACKAGE__->mk_accessors('content_type'); *paths = \&include_path; @@ -229,7 +230,8 @@ sub process { } unless ( $c->response->content_type ) { - $c->response->content_type('text/html; charset=utf-8'); + my $default = $self->content_type || 'text/html; charset=utf-8'; + $c->response->content_type($default); } $c->response->body($output); @@ -265,7 +267,7 @@ sub render { die $self->template->error if $self->{render_die}; return $self->template->error; } - $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; + $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 && $c->debug; return $self->template->error; } return $output; @@ -624,6 +626,18 @@ Then in the template: [% uri_for_css('home.css') %] +=head2 content_type + +This lets you override the default content type for the response. If you do +not set this and if you do not set the content type in your controllers, the +default is C. + +Use this if you are creating alternative view responses, such as text or JSON +and want a global setting. + +Any content type set in your controllers before calling this view are respected +and have priority. + =head2 C Allows you to change the name of the Catalyst context object. If set, it will also