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

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Sun May 20 20:16:27 EDT 2007


Author: jesse
Date: Sun May 20 20:16:26 2007
New Revision: 3275

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

Log:
 r57000 at pinglin:  jesse | 2007-05-20 20:15:49 -0400
 * Allow calling "show" with arguments
 


Modified: Template-Declare/lib/Template/Declare.pm
==============================================================================
--- Template-Declare/lib/Template/Declare.pm	(original)
+++ Template-Declare/lib/Template/Declare.pm	Sun May 20 20:16:26 2007
@@ -202,7 +202,7 @@
     my $class    = shift;
     my $template = shift;
     local %Template::Declare::Tags::ELEMENT_ID_CACHE = ();
-    return Template::Declare::Tags::show_page($template);
+    return Template::Declare::Tags::show_page($template => \@_);
 }
 
 =head2 alias
@@ -327,8 +327,9 @@
             if (my $coderef = $alias_class->resolve_template( $dispatch_to_template, $show_private)) {
 
                 return sub {
+                    shift @_;  # Get rid of the passed-in "$self" class.
                     local $TEMPLATE_VARS->{$alias_class} = $package_vars;
-                    &$coderef($alias_class);
+                    &$coderef($alias_class, at _);
                 };
             }
 

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 20:16:26 2007
@@ -46,10 +46,10 @@
     # template "foo" ==> CallerPkg::_jifty_template_foo;
     # template "foo/bar" ==> CallerPkg::_jifty_template_foo/bar;
     my $codesub = sub {
-        local $self = $_[0] || $self || $template_class;
+        local $self = shift || $self || $template_class;
 
         #local $self = $template_class unless $self;
-        &$coderef($self);
+        &$coderef($self, at _);
     };
 
     if (wantarray) {
@@ -426,14 +426,15 @@
 
 sub show {
     my $template = shift;
+    my $args  = \@_;
     my $data;
 
     # if we're inside a template, we should show private templates
     if ( caller->isa('Template::Declare') ) {
-       _show_template( $template, 1 );
+       _show_template( $template, 1, $args );
         return Template::Declare->buffer->data;
     } else {
-        show_page( $template);
+        show_page( $template, $args);
     }
 
 }
@@ -442,11 +443,12 @@
 
 sub show_page {
     my $template        = shift;
+    my $args = \@_;
     my $INSIDE_TEMPLATE = 0;
 
     # if we're inside a template, we should show private templates
     Template::Declare->new_buffer_frame;
-    _show_template( $template, 0 );
+    _show_template( $template, 0, $args );
     my $data = Template::Declare->buffer->data;
     Template::Declare->end_buffer_frame;
     %ELEMENT_ID_CACHE = ();    # We're done. we can clear the cache
@@ -481,8 +483,8 @@
 
 sub _show_template {
     my $template        = shift;
-    my $INSIDE_TEMPLATE = shift;
-
+    my $inside_template = shift;
+    my $args = shift;
     local @TEMPLATE_STACK  = @TEMPLATE_STACK;
     $template = _resolve_relative_template_path($template);
     push @TEMPLATE_STACK, $template;
@@ -491,18 +493,18 @@
     my $callable =
         ( ref($template) && $template->isa('Template::Declare::Tag') )
         ? $template
-        : Template::Declare->resolve_template( $template, $INSIDE_TEMPLATE );
+        : Template::Declare->resolve_template( $template, $inside_template );
 
     # If the template was not found let the user know.
     unless ($callable) {
         my $msg = "The template '$template' could not be found";
-        $msg .= " (it might be private)" if !$INSIDE_TEMPLATE;
+        $msg .= " (it might be private)" if !$inside_template;
         carp $msg;
         return '';
     }
 
     Template::Declare->new_buffer_frame;
-    &$callable($self);
+    &$callable($self, @$args, "FOO");
     my $content = Template::Declare->buffer->data;
     Template::Declare->end_buffer_frame;
     Template::Declare->buffer->append($content);


More information about the Jifty-commit mailing list