Switch subinclude generation to being called on instances.
[catagits/Catalyst-View-Component-SubInclude.git] / lib / Catalyst / View / Component / SubInclude / ESI.pm
index 1c98d62..259f8cc 100644 (file)
@@ -1,6 +1,6 @@
 package Catalyst::View::Component::SubInclude::ESI;
-use warnings;
-use strict;
+use Moose;
+use namespace::clean -except => 'meta';
 
 =head1 NAME
 
@@ -8,11 +8,11 @@ Catalyst::View::Component::SubInclude::ESI - Edge Side Includes (ESI) plugin for
 
 =head1 VERSION
 
-Version 0.02
+Version 0.07
 
 =cut
 
-our $VERSION = '0.02';
+our $VERSION = '0.07';
 
 =head1 SYNOPSIS
 
@@ -39,11 +39,13 @@ uses of includes.
 
 =head1 CLASS METHODS
 
-=head2 C<generate_subinclude( $c, @args )>
+=head2 C<generate_subinclude( $c, $path, @args )>
 
-This will roughly translate to the following code:
+Note that C<$path> should be the private action path - translation to the public
+path is handled internally. After translation, this will roughly translate to 
+the following code:
 
-  my $url = $c->uri_for( @args );
+  my $url = $c->uri_for( $translated_path, @args )->path_query;
   return '<!--esi <esi:include src="$url" /> -->';
 
 Notice that the stash will always be empty. This behavior could be configurable
@@ -53,10 +55,11 @@ common interface for plugins.
 =cut
 
 sub generate_subinclude {
-    my $class = shift;
-    my $c     = shift;
-    my $url = $c->uri_for( @_ );
-    return '<!--esi <esi:include src="' . $url->path . '" /> -->';
+    my ($self, $c, $path, @params) = @_;
+
+    my $uri = $c->uri_for_action( $path, @params );
+
+    return '<!--esi <esi:include src="' . $uri->path_query . '" /> -->';
 }
 
 =head1 SEE ALSO
@@ -84,4 +87,5 @@ under the same terms as Perl itself.
 
 =cut
 
+__PACKAGE__->meta->make_immutable;
 1;