[Jifty-commit] r2390 - in Template-Declare: lib/Template lib/Template/Declare

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Sat Dec 16 17:22:37 EST 2006


Author: jesse
Date: Sat Dec 16 17:22:36 2006
New Revision: 2390

Modified:
   Template-Declare/   (props changed)
   Template-Declare/lib/Template/Declare.pm
   Template-Declare/lib/Template/Declare/Tags.pm

Log:
 r46213 at 66:  jesse | 2006-12-16 12:57:42 -0800
 * still not working right. 
 * Code cleanup


Modified: Template-Declare/lib/Template/Declare.pm
==============================================================================
--- Template-Declare/lib/Template/Declare.pm	(original)
+++ Template-Declare/lib/Template/Declare.pm	Sat Dec 16 17:22:36 2006
@@ -32,36 +32,28 @@
     my $pkg           = shift;
     my $template_name = shift;
     my $show_private  = 0 || shift;
-    $template_name =~ s{/}{::}g;
+    $template_name =~ s{/+}{::}g;
 
 
-    $pkg = ref($pkg) || $pkg;
 
     if ( $template_name =~ /(.*)::(.*)/ ) {
         # Qualified name - Need to search for ISA chain
-        my $class = "$pkg\::$1";
-        my $rv    = (
-            Template::Declare::_resolve_template( $class, $2, $show_private )
-        );
+        my $class = ( ref($pkg) ? ref($pkg) : $pkg). "::" .$1;
+        my $rv    = _resolve_template( $class, $2, $show_private );
+        
         if ($rv) {
-            return ( $class, $rv );
+            return (  $rv );
         }
         no strict 'refs';
         foreach my $parent ( @{"$pkg\::ISA"} ) {
             $parent->can('has_template') or next;
-            my $template_pkg;
-            ( $template_pkg, $rv ) = $parent->has_template( $template_name, $show_private );
-            return ( $template_pkg, $rv ) if $rv;
+            ( $rv ) = $parent->has_template( $template_name, $show_private );
+            return ( $rv ) if $rv;
         }
     } else {
 
         # Unqualified name
-        return (
-            $pkg,
-            Template::Declare::_resolve_template(
-                $pkg, $template_name, $show_private
-            )
-        );
+        return  _resolve_template( $pkg, $template_name, $show_private);
     }
     return undef;
 }

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 17:22:36 2006
@@ -259,33 +259,27 @@
 
     my $template = shift;
 
-    my $buf      = '';
+    my $buf = '';
 
-    # $pkg is the package the template is actually in.
-    my $pkg = $self;
     my $INSIDE_TEMPLATE = 0;
-    my $caller = caller();
-    if ($caller->isa('Template::Declare')) { $INSIDE_TEMPLATE = 1; }
+    my $caller          = caller();
+    if ( $caller->isa('Template::Declare') ) { $INSIDE_TEMPLATE = 1; }
     {
         local $BUFFER = '';
 
-        my ($callable);
+        my $callable;
         if ( ref($template) eq 'CODE' ) {
             $callable = $template;
-        }
-        else {
+        } else {
             # if we're inside a template, we should show private templates
-           ($pkg, $callable)  = $self->has_template($template, $INSIDE_TEMPLATE);
+            $callable = $self->has_template( $template, $INSIDE_TEMPLATE );
         }
 
         # may want to just use the return value of has_template eventually
-        
-        if ($callable ){
-
+        if ($callable) {
             no strict 'refs';
-                        &$callable($pkg, @_ );
+            &$callable( $self, @_ );
         }
-
         $buf = $BUFFER;
     }
 


More information about the Jifty-commit mailing list