X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-View-Component-SubInclude.git;a=blobdiff_plain;f=lib%2FCatalyst%2FView%2FComponent%2FSubInclude%2FVisit.pm;h=5cfc85a8cff9419184486a034cd5930379d8e635;hp=c50d9eca049aa5578fdbabbe779e23c38c971154;hb=f97c716560e114d118695339a200fe5a7e09e9e5;hpb=84616d2a8aa249873c1b4b5524234e30956eee9e diff --git a/lib/Catalyst/View/Component/SubInclude/Visit.pm b/lib/Catalyst/View/Component/SubInclude/Visit.pm index c50d9ec..5cfc85a 100644 --- a/lib/Catalyst/View/Component/SubInclude/Visit.pm +++ b/lib/Catalyst/View/Component/SubInclude/Visit.pm @@ -1,9 +1,8 @@ package Catalyst::View::Component::SubInclude::Visit; -use warnings; -use strict; - +use Moose; use Carp qw/croak/; -use namespace::clean qw/croak/; +use MooseX::Types::Moose qw/ Bool /; +use namespace::clean -except => 'meta'; =head1 NAME @@ -11,11 +10,11 @@ Catalyst::View::Component::SubInclude::Visit - visit() plugin for C::V::Componen =head1 VERSION -Version 0.04 +Version 0.07 =cut -our $VERSION = '0.04'; +our $VERSION = '0.07'; =head1 SYNOPSIS @@ -58,23 +57,28 @@ with the other plugins. =cut +has keep_stash => ( + isa => Bool, + is => 'ro', + default => 0, +); + sub generate_subinclude { - my ($class, $c, $path, @params) = @_; + my ($self, $c, $path, @params) = @_; croak "subincludes through visit() require Catalyst version 5.71000 or newer" unless $c->can('visit'); - - $c->log->debug("generate subinclude: $path @params"); { - local $c->{stash} = {}; + local $c->{stash} = $self->keep_stash ? $c->{stash} : {}; local $c->request->{parameters} = ref $params[-1] eq 'HASH' ? pop @params : {}; local $c->response->{body}; - $c->visit( $path, ( ref $params[0] eq 'ARRAY' ? shift @params : () ) ); + my $captures = ref $params[0] eq 'ARRAY' ? shift @params : []; + $c->visit( $path, $captures, \@params ); return $c->response->{body}; } @@ -105,4 +109,5 @@ under the same terms as Perl itself. =cut +__PACKAGE__->meta->make_immutable; 1;