[Jifty-commit] r3272 - in Template-Declare: lib/Template/Declare t
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Sun May 20 17:51:35 EDT 2007
Author: jesse
Date: Sun May 20 17:51:35 2007
New Revision: 3272
Modified:
Template-Declare/ (props changed)
Template-Declare/lib/Template/Declare/Tags.pm
Template-Declare/t/subtemplates.t
Log:
r56997 at pinglin: jesse | 2007-05-20 17:51:13 -0400
* made relative template paths work
Modified: Template-Declare/lib/Template/Declare/Tags.pm
==============================================================================
--- Template-Declare/lib/Template/Declare/Tags.pm (original)
+++ Template-Declare/lib/Template/Declare/Tags.pm Sun May 20 17:51:35 2007
@@ -15,6 +15,7 @@
our %ATTRIBUTES = ();
our %ELEMENT_ID_CACHE = ();
our $TAG_NEST_DEPTH = 0;
+our @TEMPLATE_STACK;
=head1 NAME
@@ -453,11 +454,32 @@
return $data;
}
+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));
+ }
+
+
+
+}
+
sub _show_template {
my $template = shift;
my $INSIDE_TEMPLATE = shift;
-
+ local @TEMPLATE_STACK = @TEMPLATE_STACK;
+ $template = _resolve_relative_template_path($template);
+ push @TEMPLATE_STACK, $template;
my $callable =
@@ -478,7 +500,6 @@
my $content = Template::Declare->buffer->data;
Template::Declare->end_buffer_frame;
Template::Declare->buffer->append($content);
-
}
sub _escape_html {
Modified: Template-Declare/t/subtemplates.t
==============================================================================
--- Template-Declare/t/subtemplates.t (original)
+++ Template-Declare/t/subtemplates.t Sun May 20 17:51:35 2007
@@ -32,7 +32,7 @@
template 'my/wrapper' => sub {
- show 'content';
+ show './content';
};
More information about the Jifty-commit
mailing list