Fix plugin links in POD
[catagits/Catalyst-View-Component-SubInclude.git] / lib / Catalyst / View / Component / SubInclude / ESI.pm
CommitLineData
30726632 1package Catalyst::View::Component::SubInclude::ESI;
8bbd65bf 2use Moose;
3use namespace::clean -except => 'meta';
30726632 4
4e327756 5=head1 NAME
6
7Catalyst::View::Component::SubInclude::ESI - Edge Side Includes (ESI) plugin for C::V::Component::SubInclude
8
9=head1 VERSION
10
bff1b853 11Version 0.07_03
4e327756 12
13=cut
14
bff1b853 15our $VERSION = '0.07_03';
16$VERSION = eval $VERSION;
4e327756 17
18=head1 SYNOPSIS
19
20In your view class:
21
22 package MyApp::View::TT;
23 use Moose;
24
25 extends 'Catalyst::View::TT';
26 with 'Catalyst::View::Component::SubInclude';
27
28 __PACKAGE__->config( subinclude_plugin => 'ESI' );
29
30Then, somewhere in your templates:
31
32 [% subinclude('/my/widget') %]
33
34=head1 DESCRIPTION
35
36C<Catalyst::View::Component::SubInclude::ESI> renders C<subinclude> calls as
37Edge Side Includes (ESI) include directives. This is a feature implemented by
38Varnish (L<http://varnish.projects.linpro.no/>) which allows cache-efficient
39uses of includes.
40
c7c06ff0 41=head1 METHODS
4e327756 42
532f3bcf 43=head2 C<generate_subinclude( $c, $path, @args )>
4e327756 44
532f3bcf 45Note that C<$path> should be the private action path - translation to the public
46path is handled internally. After translation, this will roughly translate to
47the following code:
4e327756 48
532f3bcf 49 my $url = $c->uri_for( $translated_path, @args )->path_query;
11a93ea1 50 return '<!--esi <esi:include src="$url" /> -->';
4e327756 51
52Notice that the stash will always be empty. This behavior could be configurable
53in the future through an additional switch - for now, this behavior guarantees a
54common interface for plugins.
55
56=cut
57
30726632 58sub generate_subinclude {
f97c7165 59 my ($self, $c, $path, @params) = @_;
aea6a2da 60
edc887a1 61 my $uri = $c->uri_for_action( $path, @params );
aea6a2da 62
3c5cb6d6 63 return '<!--esi <esi:include src="' . $uri->path_query . '" /> -->';
30726632 64}
65
4e327756 66=head1 SEE ALSO
67
68L<Catalyst::View::Component::SubInclude|Catalyst::View::Component::SubInclude>,
69L<http://www.catalystframework.org/calendar/2008/17>,
70L<http://varnish.projects.linpro.no/>
71
72=head1 AUTHOR
73
74Nilson Santos Figueiredo Junior, C<< <nilsonsfj at cpan.org> >>
75
76=head1 SPONSORSHIP
77
78Development sponsored by Ionzero LLC L<http://www.ionzero.com/>.
79
80=head1 COPYRIGHT & LICENSE
81
82Copyright (C) 2009 Nilson Santos Figueiredo Junior.
83
84Copyright (C) 2009 Ionzero LLC.
85
86This program is free software; you can redistribute it and/or modify it
87under the same terms as Perl itself.
88
89=cut
90
8bbd65bf 91__PACKAGE__->meta->make_immutable;
30726632 921;