Add Visit Plugin, fix SubRequest plugin bump version to 0.02
[catagits/Catalyst-View-Component-SubInclude.git] / lib / Catalyst / View / Component / SubInclude / SubRequest.pm
index 5c8cf7a..2e97236 100644 (file)
@@ -2,17 +2,20 @@ package Catalyst::View::Component::SubInclude::SubRequest;
 use warnings;
 use strict;
 
+use Carp qw/croak/;
+use namespace::clean qw/croak/;
+
 =head1 NAME
 
 Catalyst::View::Component::SubInclude::SubRequest - Sub-requests plugin for C::V::Component::SubInclude
 
 =head1 VERSION
 
-Version 0.01
+Version 0.02
 
 =cut
 
-our $VERSION = '0.01';
+our $VERSION = '0.02';
 
 =head1 SYNOPSIS
 
@@ -48,9 +51,9 @@ to render the subinclude contents.
 
 It requires L<Catalyst::Plugin::SubRequest>.
 
-=head1 STASH FUNCTION
+=head1 CLASS METHODS
 
-=head2 C<subinclude( $path, @args )>
+=head2 C<generate_subinclude( $c, $path, @args )>
 
 This will translate to the following sub-request call:
 
@@ -68,8 +71,13 @@ sub generate_subinclude {
 
     croak "subincludes through subrequests require Catalyst::Plugin::SubRequest"
         unless $c->can('sub_request');
+    
+    my $dispatcher = $c->dispatcher;
+    my ($action, $args) = $dispatcher->_invoke_as_path( $c, $path, @params );
+
+    my $uri = $c->uri_for( $action, $args );
 
-    $c->sub_request( $path, $stash, @params );
+    $c->sub_request( $uri->path, $stash, @params );
 }
 
 =head1 SEE ALSO