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

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Mon Jul 9 05:05:52 EDT 2007


Author: jesse
Date: Mon Jul  9 05:05:51 2007
New Revision: 3622

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

Log:
 r60269 at 102:  jesse | 2007-07-08 22:05:34 -0700
 
 * Now handled proper relative and absolute pathing.  Tests from trs++


Modified: Template-Declare/lib/Template/Declare/Tags.pm
==============================================================================
--- Template-Declare/lib/Template/Declare/Tags.pm	(original)
+++ Template-Declare/lib/Template/Declare/Tags.pm	Mon Jul  9 05:05:51 2007
@@ -461,20 +461,24 @@
 sub _resolve_relative_template_path {
     my $template = shift;
 
-    return $template unless ($template =~ '^\.');
-    my $parent = $TEMPLATE_STACK[-1];
-  
-    my @parent = split('/',$parent);
-    my @template = split('/',$template);
-
-    if ($template[0] eq '.') {
-        shift @template; # get rid of the . 
-        pop @parent; # Get rid of the parent's tempalte name
-        return (join('/', @parent, @template));
-    }
+    return $template if ( $template =~ '^\/' );
+    my $parent = $TEMPLATE_STACK[-1] ||'';
+
+    my @parent   = split( '/', $parent );
+    my @template = split( '/', $template );
+
+    @template = grep { $_ !~ /^\.$/} @template; # Get rid of "." entries
 
+    # Let's find out how many levels they want to pop up
+    my @uplevels = grep { /^\.\.$/ } @template;
+    @template = grep { $_ !~ /^\.\.$/ } @template;
 
 
+
+    pop @parent;            # Get rid of the parent's template name
+    pop @parent for @uplevels;
+    return (join( '/', @parent, @template ) );
+
 }
 
 sub _show_template {
@@ -499,6 +503,7 @@
         return '';
     }
 
+
     Template::Declare->new_buffer_frame;
     &$callable($self, @$args);
     my $content = Template::Declare->buffer->data;


More information about the Jifty-commit mailing list