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