Commit | Line | Data |
e88af283 |
1 | package Catalyst::View::Component::SubInclude::Visit; |
2 | use warnings; |
3 | use strict; |
4 | |
5 | use Carp qw/croak/; |
6 | use namespace::clean qw/croak/; |
7 | |
8 | =head1 NAME |
9 | |
10 | Catalyst::View::Component::SubInclude::Visit - visit() plugin for C::V::Component::SubInclude |
11 | |
12 | =head1 VERSION |
13 | |
14 | Version 0.02 |
15 | |
16 | =cut |
17 | |
18 | our $VERSION = '0.02'; |
19 | |
20 | =head1 SYNOPSIS |
21 | |
22 | In 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 | |
32 | Then, somewhere in your templates: |
33 | |
34 | [% subinclude('/my/widget') %] |
35 | |
36 | =head1 DESCRIPTION |
37 | |
38 | C<Catalyst::View::Component::SubInclude::Visit> uses C<< $c->visit() >> to |
39 | render subinclude contents. |
40 | |
41 | This method is only supported when using L<Catalyst> version 5.71000 or newer. |
42 | |
43 | =head1 CLASS METHODS |
44 | |
45 | =head2 C<generate_subinclude( $c, $path, @args )> |
46 | |
47 | This will translate to the following call: |
48 | |
49 | $c->visit( $path, @args ); |
50 | |
51 | =cut |
52 | |
53 | sub generate_subinclude { |
54 | my ($class, $c, $path, @params) = @_; |
55 | |
56 | croak "subincludes through visit() require Catalyst version 5.71000 or newer" |
57 | unless $c->can('visit'); |
58 | |
59 | $c->visit( $path, @params ); |
60 | $c->res->{body}; |
61 | } |
62 | |
63 | =head1 SEE ALSO |
64 | |
65 | L<Catalyst::View::Component::SubInclude|Catalyst::View::Component::SubInclude>, |
66 | L<Catalyst|Catalyst> |
67 | |
68 | =head1 AUTHOR |
69 | |
70 | Nilson Santos Figueiredo Junior, C<< <nilsonsfj at cpan.org> >> |
71 | |
72 | =head1 SPONSORSHIP |
73 | |
74 | Development sponsored by Ionzero LLC L<http://www.ionzero.com/>. |
75 | |
76 | =head1 COPYRIGHT & LICENSE |
77 | |
78 | Copyright (C) 2009 Nilson Santos Figueiredo Junior. |
79 | |
80 | Copyright (C) 2009 Ionzero LLC. |
81 | |
82 | This program is free software; you can redistribute it and/or modify it |
83 | under the same terms as Perl itself. |
84 | |
85 | =cut |
86 | |
87 | 1; |