1 package Catalyst::View::Component::SubInclude::SSI;
3 use namespace::clean -except => 'meta';
7 Catalyst::View::Component::SubInclude::SSI - Server Side Includes (SSI) plugin for C::V::Component::SubInclude
15 our $VERSION = '0.09';
16 $VERSION = eval $VERSION;
22 package MyApp::View::TT;
25 extends 'Catalyst::View::TT';
26 with 'Catalyst::View::Component::SubInclude';
28 __PACKAGE__->config( subinclude_plugin => 'SSI' );
30 Then, somewhere in your templates:
32 [% subinclude('/my/widget') %]
36 C<Catalyst::View::Component::SubInclude::SSI> renders C<subinclude> calls as
37 Server Side Includes (SSI) include directives. This is a feature implemented by
38 Apache (L<http://httpd.apache.org/>), nginx (L<http://wiki.nginx.org/Main>)
39 and many other web servers which allows cache-efficient uses of includes.
43 =head2 C<generate_subinclude( $c, $path, @args )>
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
49 my $url = $c->uri_for( $translated_path, @args )->path_query;
50 return '<!--#include virtual="$url" -->';
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.
58 sub generate_subinclude {
59 my ($self, $c, $path, @params) = @_;
61 my $uri = $c->uri_for_action( $path, @params );
63 return '<!--#include virtual="' . $uri->path_query . '" -->';
68 L<Catalyst::View::Component::SubInclude|Catalyst::View::Component::SubInclude>,
72 Vladimir Timofeev, C<< <vovkasm at gmail.com> >>
74 =head1 COPYRIGHT & LICENSE
76 This program is free software; you can redistribute it and/or modify it
77 under the same terms as Perl itself.
81 __PACKAGE__->meta->make_immutable;