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
=head1 VERSION
-Version 0.03
+Version 0.07
=cut
-our $VERSION = '0.03';
+our $VERSION = '0.07';
=head1 SYNOPSIS
=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};
}
=cut
+__PACKAGE__->meta->make_immutable;
1;