Version 0.10
[catagits/Catalyst-View-Component-SubInclude.git] / lib / Catalyst / View / Component / SubInclude / SSI.pm
CommitLineData
6582f7e5 1package Catalyst::View::Component::SubInclude::SSI;
2use Moose;
3use namespace::clean -except => 'meta';
4
5=head1 NAME
6
7Catalyst::View::Component::SubInclude::SSI - Server Side Includes (SSI) plugin for C::V::Component::SubInclude
8
9=head1 VERSION
10
30751dc9 11Version 0.10
6582f7e5 12
13=cut
14
30751dc9 15our $VERSION = '0.10';
6582f7e5 16$VERSION = eval $VERSION;
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 => 'SSI' );
29
30Then, somewhere in your templates:
31
32 [% subinclude('/my/widget') %]
33
34=head1 DESCRIPTION
35
36C<Catalyst::View::Component::SubInclude::SSI> renders C<subinclude> calls as
37Server Side Includes (SSI) include directives. This is a feature implemented by
38Apache (L<http://httpd.apache.org/>), nginx (L<http://wiki.nginx.org/Main>)
39and many other web servers which allows cache-efficient uses of includes.
40
c7c06ff0 41=head1 METHODS
6582f7e5 42
43=head2 C<generate_subinclude( $c, $path, @args )>
44
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:
48
49 my $url = $c->uri_for( $translated_path, @args )->path_query;
87482346 50 return '<!--#include virtual="$url" -->';
6582f7e5 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
58sub generate_subinclude {
59 my ($self, $c, $path, @params) = @_;
60
61 my $uri = $c->uri_for_action( $path, @params );
62
87482346 63 return '<!--#include virtual="' . $uri->path_query . '" -->';
6582f7e5 64}
65
66=head1 SEE ALSO
67
68L<Catalyst::View::Component::SubInclude|Catalyst::View::Component::SubInclude>,
69
70=head1 AUTHOR
71
72Vladimir Timofeev, C<< <vovkasm at gmail.com> >>
73
74=head1 COPYRIGHT & LICENSE
75
76This program is free software; you can redistribute it and/or modify it
77under the same terms as Perl itself.
78
79=cut
80
81__PACKAGE__->meta->make_immutable;
821;