[Jifty-commit] r2393 - in Template-Declare: lib/Template
lib/Template/Declare
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Sat Dec 16 22:48:04 EST 2006
Author: jesse
Date: Sat Dec 16 22:48:04 2006
New Revision: 2393
Modified:
Template-Declare/ (props changed)
Template-Declare/lib/Template/Declare.pm
Template-Declare/lib/Template/Declare/Tags.pm
Log:
r46219 at pinglin: jesse | 2006-12-16 20:44:13 -0500
* Removed the old inheritance system
Modified: Template-Declare/lib/Template/Declare.pm
==============================================================================
--- Template-Declare/lib/Template/Declare.pm (original)
+++ Template-Declare/lib/Template/Declare.pm Sat Dec 16 22:48:04 2006
@@ -3,6 +3,11 @@
package Template::Declare;
+
+use base 'Class::Data::Inheritable';
+__PACKAGE__->mk_classdata('template_packages');
+
+
$Template::Declare::VERSION = "0.00_01";
=head1 NAME
@@ -24,7 +29,11 @@
Crawling all over, baby. Be very, very careful. This code is so cutting edge, it can only be fashioned from carbon nanotubes.
-The only real documentation is in t/trivial.t
+
+=cut
+
+
+=head2 has_template
=cut
@@ -32,30 +41,7 @@
my $pkg = shift;
my $template_name = shift;
my $show_private = 0 || shift;
- $template_name =~ s{/+}{::}g;
-
-
-
- if ( $template_name =~ /(.*)::(.*)/ ) {
- # Qualified name - Need to search for ISA chain
- my $class = ( ref($pkg) ? ref($pkg) : $pkg). "::" .$1;
- my $rv = _resolve_template( $class, $2, $show_private );
-
- if ($rv) {
- return ( $rv );
- }
- no strict 'refs';
- foreach my $parent ( @{"$pkg\::ISA"} ) {
- $parent->can('has_template') or next;
- ( $rv ) = $parent->has_template( $template_name, $show_private );
- return ( $rv ) if $rv;
- }
- } else {
-
- # Unqualified name
- return _resolve_template( $pkg, $template_name, $show_private);
- }
- return undef;
+ return _resolve_template( $pkg, $template_name, $show_private);
}
Modified: Template-Declare/lib/Template/Declare/Tags.pm
==============================================================================
--- Template-Declare/lib/Template/Declare/Tags.pm (original)
+++ Template-Declare/lib/Template/Declare/Tags.pm Sat Dec 16 22:48:04 2006
@@ -36,36 +36,25 @@
}
sub template ($$) {
- my $template_name = shift;
- my $coderef = shift;
- my $caller = ( caller(0) )[0];
+ my $template_name = shift;
+ my $coderef = shift;
+ my $template_class = ( caller(0) )[0];
no warnings qw( uninitialized redefine );
# template "foo" ==> CallerPkg::_jifty_template_foo;
- # template "foo/bar" ==> CallerPkg::foo::_jifty_template_bar;
-
- my $template_subname;
- my $base_name;
- my $template_class;
- if ($template_name =~ m{(.*/)?(.*)}) {
- my $subpkg = $1;
- $base_name = $2;
- $template_class = join('/',(caller(0))[0], $subpkg);
- $template_class =~ s{/+}{::}g;
- $template_class =~ s{::$}{}g;
- }
-
-
+ # template "foo/bar" ==> CallerPkg::_jifty_template_foo/bar;
+
no strict 'refs';
my $codesub = sub { shift; goto &$coderef };
- if ( wantarray) {
- return ($template_class, $base_name, $codesub);
- }
- else {
- *{ $template_class .'::' . Template::Declare::_template_name_to_sub($base_name); } = $codesub;
+ if (wantarray) {
+ return ( $template_class, $template_name, $codesub );
+ } else {
+ *{ $template_class . '::'
+ . Template::Declare::_template_name_to_sub($template_name); }
+ = $codesub;
}
}
More information about the Jifty-commit
mailing list