X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FView%2FComponent%2FSubInclude.pm;h=33c2b063e4e8606ae31b15cd24c775b2cf44b144;hb=4162256ab5c7c2446154a05e8c5dfdf1bd9a9a53;hp=63ae8b95ef0d31799397a56c5f3e8b03eeb71a6d;hpb=525a3e3b8ce90cb96978bca5240da8d5ddd9c626;p=catagits%2FCatalyst-View-Component-SubInclude.git diff --git a/lib/Catalyst/View/Component/SubInclude.pm b/lib/Catalyst/View/Component/SubInclude.pm index 63ae8b9..33c2b06 100644 --- a/lib/Catalyst/View/Component/SubInclude.pm +++ b/lib/Catalyst/View/Component/SubInclude.pm @@ -15,11 +15,11 @@ Catalyst::View::Component::SubInclude - Use subincludes in your Catalyst views =head1 VERSION -Version 0.08 +Version 0.11 =cut -our $VERSION = '0.08'; +our $VERSION = '0.11'; $VERSION = eval $VERSION; =head1 SYNOPSIS @@ -49,11 +49,7 @@ in your page. It's built in an extensible way so that you're free to use sub-requests, Varnish ESI (L) or any other -sub-include plugin you might want to implement. An LWP plugin seems useful and -might be developed in the future. If you need to address a resource by it's -public path (i.e. the path part trailing C then you -will need to use L directly, and not this -component. +sub-include plugin you might want to implement. =head1 STASH FUNCTIONS @@ -85,11 +81,25 @@ By default, the C plugin will be used. This can be changed in the view's configuration options (either in the config file or in the view module itself). -Configuration file example: + __PACKAGE__->config( + subinclude_plugin => 'ESI', + subinclude => { + 'SubRequest' => { + keep_stash => 1, + }, + 'HTTP::POST' => { + class => 'HTTP', + http_method => 'POST', + ua_timeout => '10', + uri_map => { + '/foo/' => 'http://www.foo.com/', + }, + }, + }, + ); - - subinclude_plugin ESI - +You can change each plugins' configuration through the keys in the 'subinclude' +config key (example above) =head2 C @@ -116,6 +126,12 @@ has 'subinclude_plugin' => ( isa => Str, ); +has subinclude => ( + is => 'ro', + isa => HashRef, + default => sub { {} }, +); + around 'new' => sub { my $next = shift; my $class = shift; @@ -162,19 +178,23 @@ has _subinclude_plugin_class_instance_cache => ( sub _subinclude_plugin_class_instance { my ($self, $plugin) = @_; - my $class = $plugin =~ /::/ ? $plugin : __PACKAGE__ . '::' . $plugin; - my $cache = $self->_subinclude_plugin_class_instance_cache; return $cache->{$plugin} if exists $cache->{$plugin}; my $plugin_config = Catalyst::Utils::merge_hashes( - $self->config->{subinclude}->{ALL}||{}, - $self->config->{subinclude}->{$plugin}||{} + $self->subinclude->{ALL}||{}, + $self->subinclude->{$plugin}||{} ); + my $short_class = $plugin_config->{'class'} ? + delete $plugin_config->{'class'} + : $plugin; + my $class = $short_class =~ /::/ ? + $short_class + : __PACKAGE__ . '::' . $short_class; Class::MOP::load_class($class); - return $cache->{$plugin} = $class->new($plugin_config); + return $cache->{$class} = $class->new($plugin_config); } =head1 SEE ALSO @@ -199,6 +219,10 @@ Nilson Santos Figueiredo Junior, C<< >> Tomas Doran (t0m) C<< >. +Vladimir Timofeev, C<< >>. + +Wallace Reis (wreis) C<< >>. + =head1 SPONSORSHIP Development sponsored by Ionzero LLC L.