All docs updated.
[catagits/Catalyst-View-Component-SubInclude.git] / lib / Catalyst / View / Component / SubInclude / SubRequest.pm
CommitLineData
30726632 1package Catalyst::View::Component::SubInclude::SubRequest;
2use warnings;
3use strict;
4
4e327756 5=head1 NAME
6
7Catalyst::View::Component::SubInclude::SubRequest - Sub-requests plugin for C::V::Component::SubInclude
8
9=head1 VERSION
10
11Version 0.01
12
13=cut
14
15our $VERSION = '0.01';
16
17=head1 SYNOPSIS
18
19In your application class:
20
21 package MyApp;
22
23 use Catalyst qw/
24 ConfigLoader
25 Static::Simple
26 ...
27 SubRequest
28 /;
29
30In your view class:
31
32 package MyApp::View::TT;
33 use Moose;
34
35 extends 'Catalyst::View::TT';
36 with 'Catalyst::View::Component::SubInclude';
37
38 __PACKAGE__->config( subinclude_plugin => 'SubRequest' );
39
40Then, somewhere in your templates:
41
42 [% subinclude('/my/widget') %]
43
44=head1 DESCRIPTION
45
46C<Catalyst::View::Component::SubInclude::SubRequest> uses Catalyst sub-requests
47to render the subinclude contents.
48
49It requires L<Catalyst::Plugin::SubRequest>.
50
51=head1 STASH FUNCTION
52
53=head2 C<subinclude( $path, @args )>
54
55This will translate to the following sub-request call:
56
57 $c->sub_request( $path, {}, @args );
58
59Notice that the stash will always be empty. This behavior could be configurable
60in the future through an additional switch - for now, this behavior guarantees a
61common interface for plugins.
62
63=cut
64
30726632 65sub generate_subinclude {
4e327756 66 my ($class, $c, $path, @params) = @_;
30726632 67 my $stash = {};
68
69 croak "subincludes through subrequests require Catalyst::Plugin::SubRequest"
70 unless $c->can('sub_request');
71
4e327756 72 $c->sub_request( $path, $stash, @params );
30726632 73}
74
4e327756 75=head1 SEE ALSO
76
77L<Catalyst::View::Component::SubInclude|Catalyst::View::Component::SubInclude>,
78L<Catalyst::Plugin::SubRequest|Catalyst::Plugin::SubRequest>
79
80=head1 AUTHOR
81
82Nilson Santos Figueiredo Junior, C<< <nilsonsfj at cpan.org> >>
83
84=head1 SPONSORSHIP
85
86Development sponsored by Ionzero LLC L<http://www.ionzero.com/>.
87
88=head1 COPYRIGHT & LICENSE
89
90Copyright (C) 2009 Nilson Santos Figueiredo Junior.
91
92Copyright (C) 2009 Ionzero LLC.
93
94This program is free software; you can redistribute it and/or modify it
95under the same terms as Perl itself.
96
97=cut
98
30726632 991;