[Templates-cvs] cvs commit: Template2/lib/Template Context.pm

cvs@template-toolkit.org cvs@template-toolkit.org
Mon, 04 Oct 2004 11:02:30 +0100


cvs         04/10/04 10:02:29

  Modified:    lib/Template Context.pm
  Log:
  * fixed (well, half-fixed) the callers bug which didn't remove callers
    from the callers list after processing a template component
    http://template-toolkit.org/pipermail/templates/2004-April/006070.html
  
  Revision  Changes    Path
  2.91      +13 -3     Template2/lib/Template/Context.pm
  
  Index: Context.pm
  ===================================================================
  RCS file: /template-toolkit/Template2/lib/Template/Context.pm,v
  retrieving revision 2.90
  retrieving revision 2.91
  diff -u -r2.90 -r2.91
  --- Context.pm	2004/01/30 19:32:23	2.90
  +++ Context.pm	2004/10/04 10:02:29	2.91
  @@ -18,7 +18,7 @@
   #   modify it under the same terms as Perl itself.
   # 
   # REVISION
  -#   $Id: Context.pm,v 2.90 2004/01/30 19:32:23 abw Exp $
  +#   $Id: Context.pm,v 2.91 2004/10/04 10:02:29 abw Exp $
   #
   #============================================================================
   
  @@ -35,7 +35,7 @@
   use Template::Constants;
   use Template::Exception;
   
  -$VERSION = sprintf("%d.%02d", q$Revision: 2.90 $ =~ /(\d+)\.(\d+)/);
  +$VERSION = sprintf("%d.%02d", q$Revision: 2.91 $ =~ /(\d+)\.(\d+)/);
   $DEBUG_FORMAT = "\n## \$file line \$line : [% \$text %] ##\n";
   
   
  @@ -325,7 +325,7 @@
               $compiled = shift @compiled;
               my $element = ref $compiled eq 'CODE' 
                   ? { (name => (ref $name ? '' : $name), modtime => time()) }
  -	        : $compiled;
  +                : $compiled;
   
               if (UNIVERSAL::isa($component, 'Template::Document')) {
                   $element->{ caller } = $component->{ name };
  @@ -361,6 +361,16 @@
                   }
               }
               $output .= $tmpout;
  +
  +            # pop last item from callers.  
  +            # NOTE - this will not be called if template throws an 
  +            # error.  The whole issue of caller and callers should be 
  +            # revisited to try and avoid putting this info directly into
  +            # the component data structure.  Perhaps use a local element
  +            # instead?
  +
  +            pop(@{$element->{ callers }})
  +                if (UNIVERSAL::isa($element, 'Template::Document'));
           }
           $stash->set('component', $component);
       };