Doc maintenance: trash the warning about chained actions
[catagits/Catalyst-View-Component-SubInclude.git] / lib / Catalyst / View / Component / SubInclude / Visit.pm
CommitLineData
e88af283 1package Catalyst::View::Component::SubInclude::Visit;
8bbd65bf 2use Moose;
e88af283 3use Carp qw/croak/;
f97c7165 4use MooseX::Types::Moose qw/ Bool /;
8bbd65bf 5use namespace::clean -except => 'meta';
e88af283 6
7=head1 NAME
8
9Catalyst::View::Component::SubInclude::Visit - visit() plugin for C::V::Component::SubInclude
10
11=head1 VERSION
12
bff1b853 13Version 0.07_03
e88af283 14
15=cut
16
bff1b853 17our $VERSION = '0.07_03';
18$VERSION = eval $VERSION;
e88af283 19
20=head1 SYNOPSIS
21
22In your view class:
23
24 package MyApp::View::TT;
25 use Moose;
26
27 extends 'Catalyst::View::TT';
28 with 'Catalyst::View::Component::SubInclude';
29
30 __PACKAGE__->config( subinclude_plugin => 'Visit' );
31
32Then, somewhere in your templates:
33
34 [% subinclude('/my/widget') %]
35
36=head1 DESCRIPTION
37
38C<Catalyst::View::Component::SubInclude::Visit> uses C<< $c->visit() >> to
39render subinclude contents.
40
41This method is only supported when using L<Catalyst> version 5.71000 or newer.
42
c7c06ff0 43=head1 METHODS
e88af283 44
45=head2 C<generate_subinclude( $c, $path, @args )>
46
532f3bcf 47This is (roughly) equivalent to the following call:
e88af283 48
49 $c->visit( $path, @args );
50
532f3bcf 51But it will handle all the nasty details such as localizing the stash,
52parameters and response body. This is necessary to keep behavior consistent
53with the other plugins.
54
e88af283 55=cut
56
f97c7165 57has keep_stash => (
58 isa => Bool,
59 is => 'ro',
60 default => 0,
61);
62
e88af283 63sub generate_subinclude {
f97c7165 64 my ($self, $c, $path, @params) = @_;
e88af283 65
66 croak "subincludes through visit() require Catalyst version 5.71000 or newer"
67 unless $c->can('visit');
3c5cb6d6 68
69 {
f97c7165 70 local $c->{stash} = $self->keep_stash ? $c->{stash} : {};
3c5cb6d6 71
72 local $c->request->{parameters} =
73 ref $params[-1] eq 'HASH' ? pop @params : {};
74
75 local $c->response->{body};
76
9c2c47b0 77 my $captures = ref $params[0] eq 'ARRAY' ? shift @params : [];
be1a1092 78 $c->visit( $path, $captures, \@params );
3c5cb6d6 79
80 return $c->response->{body};
81 }
e88af283 82
e88af283 83}
84
85=head1 SEE ALSO
86
87L<Catalyst::View::Component::SubInclude|Catalyst::View::Component::SubInclude>,
88L<Catalyst|Catalyst>
89
90=head1 AUTHOR
91
92Nilson Santos Figueiredo Junior, C<< <nilsonsfj at cpan.org> >>
93
94=head1 SPONSORSHIP
95
96Development sponsored by Ionzero LLC L<http://www.ionzero.com/>.
97
98=head1 COPYRIGHT & LICENSE
99
100Copyright (C) 2009 Nilson Santos Figueiredo Junior.
101
102Copyright (C) 2009 Ionzero LLC.
103
104This program is free software; you can redistribute it and/or modify it
105under the same terms as Perl itself.
106
107=cut
108
8bbd65bf 109__PACKAGE__->meta->make_immutable;
e88af283 1101;