[Jifty-commit] r7534 - in Template-Declare/branches/mixmaster: t
Jifty commits
jifty-commit at lists.jifty.org
Sat Oct 10 01:07:11 EDT 2009
Author: theory
Date: Sat Oct 10 01:07:10 2009
New Revision: 7534
Modified:
Template-Declare/branches/mixmaster/lib/Template/Declare.pm
Template-Declare/branches/mixmaster/t/aliasing.t
Template-Declare/branches/mixmaster/t/importing.t
Template-Declare/branches/mixmaster/t/mixing.t
Log:
Changed mixin behavior so that the class passed to templates is the class that was mixed in, rather than the class in which the template is defined. This is how `alias` behaved in the past, but not `import_templates`. Which is more correct? Will this break existing uses of `import_templates`? Will I end up having to make `import_templates` behave as it did in the past, inconsistently with `alias` and now `mix`? Enquiring minds want to know!
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 Sat Oct 10 01:07:10 2009
@@ -830,27 +830,27 @@
for my $tname ( __PACKAGE__->_templates_for($from) ) {
$into->register_template(
"$prefix/$tname",
- _import_code( $tname, $from, $vars )
+ _import_code( $tname, $from, $mixin, $vars )
);
}
for my $tname ( __PACKAGE__->_private_templates_for($from) ) {
$into->register_private_template(
"$prefix/$tname",
- _import_code( $tname, $from, $vars )
+ _import_code( $tname, $from, $mixin, $vars )
);
}
}
}
sub _import_code {
- my ($tname, $class, $vars) = @_;
- my $code = $class->_find_template_sub( _template_name_to_sub($tname) );
- return $code unless $vars;
+ my ($tname, $from, $to, $vars) = @_;
+ my $code = $from->_find_template_sub( _template_name_to_sub($tname) );
+ return $to eq $from ? $code : sub { $code->($to, @_) } unless $vars;
return sub {
# XXX This does not seem to be needed.
# shift @_; # Get rid of the passed-in "$self" class.
- local $TEMPLATE_VARS->{$class} = $vars;
- $code->($class, @_);
+ local $TEMPLATE_VARS->{$from} = $vars;
+ $code->($to, @_);
};
}
Modified: Template-Declare/branches/mixmaster/t/aliasing.t
==============================================================================
--- Template-Declare/branches/mixmaster/t/aliasing.t (original)
+++ Template-Declare/branches/mixmaster/t/aliasing.t Sat Oct 10 01:07:10 2009
@@ -90,7 +90,7 @@
);
like(
$simple,
- qr{'Wifty::UI::aliased_pkg'},
+ qr{'Wifty::UI::aliased_subclass_pkg'},
'$self is correct in template block'
);
ok_lint($simple);
Modified: Template-Declare/branches/mixmaster/t/importing.t
==============================================================================
--- Template-Declare/branches/mixmaster/t/importing.t (original)
+++ Template-Declare/branches/mixmaster/t/importing.t Sat Oct 10 01:07:10 2009
@@ -106,7 +106,7 @@
);
like(
$simple,
- qr{'Wifty::UI::imported_pkg'},
+ qr{'Wifty::UI::imported_subclass_pkg'},
'$self is correct in template block'
);
ok_lint($simple);
Modified: Template-Declare/branches/mixmaster/t/mixing.t
==============================================================================
--- Template-Declare/branches/mixmaster/t/mixing.t (original)
+++ Template-Declare/branches/mixmaster/t/mixing.t Sat Oct 10 01:07:10 2009
@@ -116,7 +116,7 @@
);
like(
$simple,
- qr{'Wifty::UI::mixed_pkg'},
+ qr{'Wifty::UI::mixed_subclass_pkg'},
'$self is correct in template block'
);
ok_lint($simple);
More information about the Jifty-commit
mailing list