X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-View-Component-SubInclude.git;a=blobdiff_plain;f=lib%2FCatalyst%2FView%2FComponent%2FSubInclude.pm;h=dd0caeaeb23e7be5663a08c1f49a780f21d0c1b1;hp=ecdeff019acb8e56a37e380cee083e12e0e43dac;hb=f97c716560e114d118695339a200fe5a7e09e9e5;hpb=9399de67c73e690611087f7aa359537a7bef4b46 diff --git a/lib/Catalyst/View/Component/SubInclude.pm b/lib/Catalyst/View/Component/SubInclude.pm index ecdeff0..dd0caea 100644 --- a/lib/Catalyst/View/Component/SubInclude.pm +++ b/lib/Catalyst/View/Component/SubInclude.pm @@ -2,8 +2,10 @@ package Catalyst::View::Component::SubInclude; use Moose::Role; use Carp qw/croak/; -use namespace::clean qw/croak/; -use Scalar::Util qw/weaken/; +use Catalyst::Utils (); +use namespace::clean -except => 'meta'; + +with 'Catalyst::Component::ContextClosure'; =head1 NAME @@ -120,16 +122,11 @@ around 'new' => sub { $self; }; -around 'render' => sub { - my $next = shift; +before 'render' => sub { my ($self, $c, @args) = @_; - - weaken $c; - - $c->stash->{subinclude} = sub { $self->_subinclude( $c, @_ ) }; - $c->stash->{subinclude_using} = sub { $self->_subinclude_using( $c, @_ ) }; - $self->$next( $c, @args ); + $c->stash->{subinclude} = $self->make_context_closure(sub { $self->_subinclude( @_ ) }, $c); + $c->stash->{subinclude_using} = $self->make_context_closure(sub { $self->_subinclude_using( @_ ) }, $c); }; sub set_subinclude_plugin { @@ -147,7 +144,8 @@ sub _subinclude { sub _subinclude_using { my ($self, $c, $plugin, @args) = @_; $plugin = $self->_subinclude_plugin_class_name($plugin); - $plugin->generate_subinclude( $c, @args ); + my $plugin_config = Catalyst::Utils::merge_hashes($self->config->{subinclude}->{ALL}||{}, $self->config->{subinclude}->{$plugin}||{}); + $plugin->new($plugin_config)->generate_subinclude( $c, @args ); } sub _subinclude_plugin_class_name {