[Jifty-commit] r7564 - in Template-Declare/branches/mixmaster: t
Jifty commits
jifty-commit at lists.jifty.org
Fri Oct 16 12:52:00 EDT 2009
Author: theory
Date: Fri Oct 16 12:51:59 2009
New Revision: 7564
Modified:
Template-Declare/branches/mixmaster/lib/Template/Declare.pm
Template-Declare/branches/mixmaster/t/aliasing.t
Template-Declare/branches/mixmaster/t/mixing.t
Log:
Fixed a regression where private templates where not mixed/aliased with their proper subnames.
Modified: Template-Declare/branches/mixmaster/lib/Template/Declare.pm
==============================================================================
--- Template-Declare/branches/mixmaster/lib/Template/Declare.pm (original)
+++ Template-Declare/branches/mixmaster/lib/Template/Declare.pm Fri Oct 16 12:51:59 2009
@@ -1223,7 +1223,6 @@
return $TEMPLATE_VARS->{$self};
}
-
=head2 Templates registration and lookup
=head3 resolve_template TEMPLATE_PATH INCLUDE_PRIVATE_TEMPLATES
@@ -1530,6 +1529,7 @@
my $coderef = shift;
no strict 'refs';
no warnings 'redefine';
+ die 'WTF?' unless $coderef;
*{ $class . '::' . $subname } = $coderef;
}
@@ -1560,23 +1560,25 @@
foreach my $from (@packages) {
for my $tname ( __PACKAGE__->_templates_for($from) ) {
+ my $sname = _template_name_to_sub($tname);
$into->register_template(
"$prefix/$tname",
- _import_code( $tname, $from, $invocant || $mixin, $vars )
+ _import_code( $sname, $from, $invocant || $mixin, $vars )
);
}
for my $tname ( __PACKAGE__->_private_templates_for($from) ) {
+ my $sname = _template_name_to_private_sub($tname);
$into->register_private_template(
"$prefix/$tname",
- _import_code( $tname, $from, $invocant || $mixin, $vars )
+ _import_code( $sname, $from, $invocant || $mixin, $vars )
);
}
}
}
sub _import_code {
- my ($tname, $from, $mixin, $vars) = @_;
- my $code = $from->_find_template_sub( _template_name_to_sub($tname) );
+ my ($sname, $from, $mixin, $vars) = @_;
+ my $code = $from->_find_template_sub( $sname );
return $mixin eq $from ? $code : sub { shift; $code->($mixin, @_) }
unless $vars;
return sub {
Modified: Template-Declare/branches/mixmaster/t/aliasing.t
==============================================================================
--- Template-Declare/branches/mixmaster/t/aliasing.t (original)
+++ Template-Declare/branches/mixmaster/t/aliasing.t Fri Oct 16 12:51:59 2009
@@ -12,6 +12,8 @@
div { 'Variable ', $self->package_variable('VARIABLE') };
};
+private template shhhh => sub { };
+
##############################################################################
package Wifty::UI::aliased_subclass_pkg;
use base qw/Wifty::UI::aliased_pkg/;
@@ -54,7 +56,7 @@
# Fire it up.
Template::Declare->init( dispatch_to => ['Wifty::UI'] );
-use Test::More tests => 29;
+use Test::More tests => 30;
require "t/utils.pl";
ok( Wifty::UI::aliased_pkg->has_template('aliased'), 'Aliased package should have template' );
@@ -62,6 +64,7 @@
ok( Wifty::UI::aliased_subclass_pkg->has_template('aliased'), 'Subclass should' );
ok( Template::Declare->has_template('aliased_pkg/aliased'), 'TD should find alias' );
+ok( Template::Declare->has_template('aliased_pkg2/shhhh', 1), 'TD should find private mix' );
ok( Template::Declare->has_template('aliased_subclass_pkg/aliased'),
'Alias should be visible in a subclass, too' );
Modified: Template-Declare/branches/mixmaster/t/mixing.t
==============================================================================
--- Template-Declare/branches/mixmaster/t/mixing.t (original)
+++ Template-Declare/branches/mixmaster/t/mixing.t Fri Oct 16 12:51:59 2009
@@ -12,6 +12,8 @@
div { 'Variable ', $self->package_variable('VARIABLE') };
};
+private template shhhh => sub { };
+
##############################################################################
package Wifty::UI::mixed_subclass_pkg;
use base qw/Wifty::UI::mixed_pkg/;
@@ -54,7 +56,7 @@
# Fire it up.
Template::Declare->init( dispatch_to => ['Wifty::UI'] );
-use Test::More tests => 29;
+use Test::More tests => 30;
require "t/utils.pl";
ok( Wifty::UI::mixed_pkg->has_template('mixed'), 'Mixed package should have template' );
@@ -62,6 +64,7 @@
ok( Wifty::UI::mixed_subclass_pkg->has_template('mixed'), 'Subclass should' );
ok( Template::Declare->has_template('mixed_pkg/mixed'), 'TD should find mix' );
+ok( Template::Declare->has_template('mixed_pkg2/shhhh', 1), 'TD should find private mix' );
ok( Template::Declare->has_template('mixed_subclass_pkg/mixed'),
'Mix should be visible in a subclass, too' );
More information about the Jifty-commit
mailing list