1 package Catalyst::View::Component::SubInclude::Visit;
6 use namespace::clean qw/croak/;
10 Catalyst::View::Component::SubInclude::Visit - visit() plugin for C::V::Component::SubInclude
18 our $VERSION = '0.02';
24 package MyApp::View::TT;
27 extends 'Catalyst::View::TT';
28 with 'Catalyst::View::Component::SubInclude';
30 __PACKAGE__->config( subinclude_plugin => 'Visit' );
32 Then, somewhere in your templates:
34 [% subinclude('/my/widget') %]
38 C<Catalyst::View::Component::SubInclude::Visit> uses C<< $c->visit() >> to
39 render subinclude contents.
41 This method is only supported when using L<Catalyst> version 5.71000 or newer.
45 =head2 C<generate_subinclude( $c, $path, @args )>
47 This will translate to the following call:
49 $c->visit( $path, @args );
53 sub generate_subinclude {
54 my ($class, $c, $path, @params) = @_;
56 croak "subincludes through visit() require Catalyst version 5.71000 or newer"
57 unless $c->can('visit');
59 $c->log->debug("generate subinclude: $path @params");
62 local $c->{stash} = {};
64 local $c->request->{parameters} =
65 ref $params[-1] eq 'HASH' ? pop @params : {};
67 local $c->response->{body};
69 $c->visit( $path, ( ref $params[0] eq 'ARRAY' ? shift @params : () ) );
71 return $c->response->{body};
78 L<Catalyst::View::Component::SubInclude|Catalyst::View::Component::SubInclude>,
83 Nilson Santos Figueiredo Junior, C<< <nilsonsfj at cpan.org> >>
87 Development sponsored by Ionzero LLC L<http://www.ionzero.com/>.
89 =head1 COPYRIGHT & LICENSE
91 Copyright (C) 2009 Nilson Santos Figueiredo Junior.
93 Copyright (C) 2009 Ionzero LLC.
95 This program is free software; you can redistribute it and/or modify it
96 under the same terms as Perl itself.