Don't serialize if a view is explicitly set.
Shea Levy [Fri, 15 Mar 2013 15:54:35 +0000 (11:54 -0400)]
If the controller sets the view in $c->stash->{current_view} or
$c->stash->{current_view_instance}, then it is explicitly requesting a
certain kind of serialization and C::A::Serialize shouldn't override
that.

Signed-off-by: Shea Levy <shea@shealevy.com>

lib/Catalyst/Action/Serialize.pm

index be6dda5..bd9e09a 100644 (file)
@@ -26,6 +26,8 @@ sub execute {
     return 1 if $c->response->has_body;
     return 1 if scalar @{ $c->error };
     return 1 if $c->response->status =~ /^(?:204)$/;
+    return 1 if defined $c->stash->{current_view};
+    return 1 if defined $c->stash->{current_view_instance};
 
     my ( $sclass, $sarg, $content_type ) =
       $self->_load_content_plugins( "Catalyst::Action::Serialize",