=head1 VERSION
-Version 0.01
+Version 0.02
=cut
-our $VERSION = '0.01';
+our $VERSION = '0.02';
=head1 SYNOPSIS
=head1 SUBINCLUDE PLUGINS
The module comes with two subinclude plugins:
-L<SubRequest|Catalyst::Plugin::View::Component::SubRequest> and
+L<SubRequest|Catalyst::Plugin::View::Component::SubRequest>,
+L<Visit|Catalyst::Plugin::View::Component::Visit> and
L<ESI|Catalyst::Plugin::View::Component::ESI>.
By default, the SubRequest plugin will be used. This can be changed in the
=head1 VERSION
-Version 0.01
+Version 0.02
=cut
-our $VERSION = '0.01';
+our $VERSION = '0.02';
=head1 SYNOPSIS
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 );
- $c->sub_request( $path, $stash, @params );
+ my $uri = $c->uri_for( $action, $args );
+
+ $c->sub_request( $uri->path, $stash, @params );
}
=head1 SEE ALSO
--- /dev/null
+package Catalyst::View::Component::SubInclude::Visit;
+use warnings;
+use strict;
+
+use Carp qw/croak/;
+use namespace::clean qw/croak/;
+
+=head1 NAME
+
+Catalyst::View::Component::SubInclude::Visit - visit() plugin for C::V::Component::SubInclude
+
+=head1 VERSION
+
+Version 0.02
+
+=cut
+
+our $VERSION = '0.02';
+
+=head1 SYNOPSIS
+
+In your view class:
+
+ package MyApp::View::TT;
+ use Moose;
+
+ extends 'Catalyst::View::TT';
+ with 'Catalyst::View::Component::SubInclude';
+
+ __PACKAGE__->config( subinclude_plugin => 'Visit' );
+
+Then, somewhere in your templates:
+
+ [% subinclude('/my/widget') %]
+
+=head1 DESCRIPTION
+
+C<Catalyst::View::Component::SubInclude::Visit> uses C<< $c->visit() >> to
+render subinclude contents.
+
+This method is only supported when using L<Catalyst> version 5.71000 or newer.
+
+=head1 CLASS METHODS
+
+=head2 C<generate_subinclude( $c, $path, @args )>
+
+This will translate to the following call:
+
+ $c->visit( $path, @args );
+
+=cut
+
+sub generate_subinclude {
+ my ($class, $c, $path, @params) = @_;
+
+ croak "subincludes through visit() require Catalyst version 5.71000 or newer"
+ unless $c->can('visit');
+
+ $c->visit( $path, @params );
+ $c->res->{body};
+}
+
+=head1 SEE ALSO
+
+L<Catalyst::View::Component::SubInclude|Catalyst::View::Component::SubInclude>,
+L<Catalyst|Catalyst>
+
+=head1 AUTHOR
+
+Nilson Santos Figueiredo Junior, C<< <nilsonsfj at cpan.org> >>
+
+=head1 SPONSORSHIP
+
+Development sponsored by Ionzero LLC L<http://www.ionzero.com/>.
+
+=head1 COPYRIGHT & LICENSE
+
+Copyright (C) 2009 Nilson Santos Figueiredo Junior.
+
+Copyright (C) 2009 Ionzero LLC.
+
+This program is free software; you can redistribute it and/or modify it
+under the same terms as Perl itself.
+
+=cut
+
+1;
__PACKAGE__->config->{namespace} = '';
-sub index :Path :Args(0) {
+sub index :Path Args(0) {
my ( $self, $c ) = @_;
}
-sub time_include : Local Args(0) {
+sub base : Chained('/') PathPart('') CaptureArgs(0) {
+ my ( $self, $c ) = @_;
+}
+
+sub time_include : Chained('base') PathPart('time') Args(0) {
my ( $self, $c ) = @_;
$c->stash->{current_time} = localtime();
}