X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FView%2FComponent%2FSubInclude%2FVisit.pm;h=22e2c9030aa13029050ff1427da71ecdf82361d8;hb=be1a109247778c4c844eeeeab1cf303e09175871;hp=18555899cf60edb6a995b471474275cf4352bf1d;hpb=e88af2835e002b378e700d70a81912b493b40b1f;p=catagits%2FCatalyst-View-Component-SubInclude.git diff --git a/lib/Catalyst/View/Component/SubInclude/Visit.pm b/lib/Catalyst/View/Component/SubInclude/Visit.pm index 1855589..22e2c90 100644 --- a/lib/Catalyst/View/Component/SubInclude/Visit.pm +++ b/lib/Catalyst/View/Component/SubInclude/Visit.pm @@ -11,11 +11,11 @@ Catalyst::View::Component::SubInclude::Visit - visit() plugin for C::V::Componen =head1 VERSION -Version 0.02 +Version 0.07 =cut -our $VERSION = '0.02'; +our $VERSION = '0.07'; =head1 SYNOPSIS @@ -40,14 +40,22 @@ render subinclude contents. This method is only supported when using L version 5.71000 or newer. +B. Apparently, C doesn't handle this type +of actions yet. + =head1 CLASS METHODS =head2 C -This will translate to the following call: +This is (roughly) equivalent to the following call: $c->visit( $path, @args ); +But it will handle all the nasty details such as localizing the stash, +parameters and response body. This is necessary to keep behavior consistent +with the other plugins. + =cut sub generate_subinclude { @@ -56,8 +64,20 @@ sub generate_subinclude { croak "subincludes through visit() require Catalyst version 5.71000 or newer" unless $c->can('visit'); - $c->visit( $path, @params ); - $c->res->{body}; + { + local $c->{stash} = {}; + + local $c->request->{parameters} = + ref $params[-1] eq 'HASH' ? pop @params : {}; + + local $c->response->{body}; + + my $captures = ref $params[0] eq 'ARRAY' ? shift @params : []; + $c->visit( $path, $captures, \@params ); + + return $c->response->{body}; + } + } =head1 SEE ALSO