X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FView%2FComponent%2FSubInclude%2FSubRequest.pm;h=4a81a94409c7044badcc0622fd1d1af91ddb04b2;hb=HEAD;hp=18260dc25ab14727f19bd84a3faec33693119c0a;hpb=f97c716560e114d118695339a200fe5a7e09e9e5;p=catagits%2FCatalyst-View-Component-SubInclude.git diff --git a/lib/Catalyst/View/Component/SubInclude/SubRequest.pm b/lib/Catalyst/View/Component/SubInclude/SubRequest.pm index 18260dc..4a81a94 100644 --- a/lib/Catalyst/View/Component/SubInclude/SubRequest.pm +++ b/lib/Catalyst/View/Component/SubInclude/SubRequest.pm @@ -10,11 +10,12 @@ Catalyst::View::Component::SubInclude::SubRequest - Sub-requests plugin for C::V =head1 VERSION -Version 0.07 +Version 0.07_03 =cut -our $VERSION = '0.07'; +our $VERSION = '0.07_03'; +$VERSION = eval $VERSION; =head1 SYNOPSIS @@ -46,11 +47,11 @@ Then, somewhere in your templates: =head1 DESCRIPTION C uses Catalyst sub-requests -to render the subinclude contents. +to render the subinclude contents. It requires L. -=head1 CLASS METHODS +=head1 METHODS =head2 C @@ -62,9 +63,28 @@ So, after path translation, the call will be (roughly) equivalent to: $c->sub_request( $translated_path, {}, @args ); -Notice that the stash will always be empty. This behavior could be configurable -in the future through an additional switch - for now, this behavior guarantees a -common interface for all plugins. +Notice that the stash will be empty by default. This behavior is configurable +(see below). + +=head1 CONFIGURATION + +=head2 keep_stash + +You can choose to not localize the stash for SubRequests' subinclude calls. The subrequest +will have the same stash as the request that spawned it. Configure the keep_stash key +in your view: + + __PACKAGE__->config( + subinclude => { + 'SubRequest' => { + keep_stash => 1, + }, + } + ); + +Note: the stash that the subrequest recieves is a shallow copy of the original stash. That +means that changes to values of keys on the first level of the stash will be lost when the +subrequest call returns. Don't count on this behaviour, as it may change in the future. =cut @@ -76,13 +96,13 @@ has keep_stash => ( sub generate_subinclude { my ($self, $c, $path, @params) = @_; - my $stash = $self->keep_stash ? { %{ $c->stash } } : {}; + my $stash = $self->keep_stash ? $c->stash : {}; croak "subincludes through subrequests require Catalyst::Plugin::SubRequest" unless $c->can('sub_request'); my $query = ref $params[-1] eq 'HASH' ? pop @params : {}; - + my $action = blessed($path) ? $path : $c->dispatcher->get_action_by_path($path); @@ -94,7 +114,7 @@ sub generate_subinclude { =head1 SEE ALSO -L, +L, L =head1 AUTHOR