All docs updated.
[catagits/Catalyst-View-Component-SubInclude.git] / lib / Catalyst / View / Component / SubInclude / ESI.pm
CommitLineData
30726632 1package Catalyst::View::Component::SubInclude::ESI;
2use warnings;
3use strict;
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
11Version 0.01
12
13=cut
14
15our $VERSION = '0.01';
16
17=head1 SYNOPSIS
18
19In your view class:
20
21 package MyApp::View::TT;
22 use Moose;
23
24 extends 'Catalyst::View::TT';
25 with 'Catalyst::View::Component::SubInclude';
26
27 __PACKAGE__->config( subinclude_plugin => 'ESI' );
28
29Then, somewhere in your templates:
30
31 [% subinclude('/my/widget') %]
32
33=head1 DESCRIPTION
34
35C<Catalyst::View::Component::SubInclude::ESI> renders C<subinclude> calls as
36Edge Side Includes (ESI) include directives. This is a feature implemented by
37Varnish (L<http://varnish.projects.linpro.no/>) which allows cache-efficient
38uses of includes.
39
40=head1 STASH FUNCTION
41
42=head2 C<subinclude( @args )>
43
44This will roughly translate to the following code:
45
46 my $url = $c->uri_for( @args );
47 <!--esi <esi:include src="$url" /> -->
48
49Notice that the stash will always be empty. This behavior could be configurable
50in the future through an additional switch - for now, this behavior guarantees a
51common interface for plugins.
52
53=cut
54
30726632 55sub generate_subinclude {
56 my $class = shift;
57 my $c = shift;
58 my $url = $c->uri_for( @_ );
59 return '<!--esi <esi:include src="' . $url->path . '" /> -->';
60}
61
4e327756 62=head1 SEE ALSO
63
64L<Catalyst::View::Component::SubInclude|Catalyst::View::Component::SubInclude>,
65L<http://www.catalystframework.org/calendar/2008/17>,
66L<http://varnish.projects.linpro.no/>
67
68=head1 AUTHOR
69
70Nilson Santos Figueiredo Junior, C<< <nilsonsfj at cpan.org> >>
71
72=head1 SPONSORSHIP
73
74Development sponsored by Ionzero LLC L<http://www.ionzero.com/>.
75
76=head1 COPYRIGHT & LICENSE
77
78Copyright (C) 2009 Nilson Santos Figueiredo Junior.
79
80Copyright (C) 2009 Ionzero LLC.
81
82This program is free software; you can redistribute it and/or modify it
83under the same terms as Perl itself.
84
85=cut
86
30726632 871;