Fix ESI plugin, update Makefile.PL
[catagits/Catalyst-View-Component-SubInclude.git] / lib / Catalyst / View / Component / SubInclude / ESI.pm
index f2b499a..6d763e1 100644 (file)
@@ -8,11 +8,11 @@ Catalyst::View::Component::SubInclude::ESI - Edge Side Includes (ESI) plugin for
 
 =head1 VERSION
 
-Version 0.01
+Version 0.02
 
 =cut
 
-our $VERSION = '0.01';
+our $VERSION = '0.02';
 
 =head1 SYNOPSIS
 
@@ -37,14 +37,14 @@ Edge Side Includes (ESI) include directives. This is a feature implemented by
 Varnish (L<http://varnish.projects.linpro.no/>) which allows cache-efficient 
 uses of includes.
 
-=head1 STASH FUNCTION
+=head1 CLASS METHODS
 
-=head2 C<subinclude( @args )>
+=head2 C<generate_subinclude( $c, @args )>
 
 This will roughly translate to the following code:
 
   my $url = $c->uri_for( @args );
-  <!--esi <esi:include src="$url" /> -->
+  return '<!--esi <esi:include src="$url" /> -->';
 
 Notice that the stash will always be empty. This behavior could be configurable
 in the future through an additional switch - for now, this behavior guarantees a
@@ -53,10 +53,14 @@ 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 ($class, $c, $path, @params) = @_;
+
+    my $dispatcher = $c->dispatcher;
+    my ($action, $args) = $dispatcher->_invoke_as_path( $c, $path, @params );
+
+    my $uri = $c->uri_for( $action, $args );
+
+    return '<!--esi <esi:include src="' . $uri->path . '" /> -->';
 }
 
 =head1 SEE ALSO