On Tue, 30 Oct 2001, Kenny Smith wrote:

> I'm having a problem using global variables inside my loops. I have
> global_vars => 1 in my H::T constructor, but it's not working in nested
> loops.

This is a bug, but I've finally fixed it!  Yes!  You can wait for the next
release or apply the attached patch to Template.pm.

Thanks!
-sam

Index: Template.pm
===================================================================
RCS file: /cvsroot/html-template/HTML-Template/Template.pm,v
retrieving revision 1.108
diff -u -r1.108 Template.pm
--- Template.pm 2001/08/27 19:54:58     1.108
+++ Template.pm 2001/10/31 18:15:14
@@ -717,6 +717,19 @@
 Normally this wouldn't work as expected, since <TMPL_VAR NORMAL>'s
 value outside the loop is not available inside the loop.
 
+The global_vars option also allows you to access the values of an
+enclosing loop within an inner loop.  For example, in this loop the
+inner loop will have access to the value of OUTER_VAR in the correct
+iteration:
+
+   <TMPL_LOOP OUTER_LOOP>
+      OUTER: <TMPL_VAR OUTER_VAR>
+        <TMPL_LOOP INNER_LOOP>
+           INNER: <TMPL_VAR INNER_VAR>
+           INSIDE OUT: <TMPL_VAR OUTER_VAR>
+        </TMPL_LOOP>
+   </TMPL_LOOP>
+
 =item *
 
 filter - this option allows you to specify a filter for your template
@@ -2423,7 +2436,7 @@
 
     foreach my $param (keys %{$self->{param_map}}) {
       unless (defined($self->param($param))) {
-      OBJ: foreach my $associated_object (@{$options->{associate}}) {
+      OBJ: foreach my $associated_object (reverse @{$options->{associate}}) {
           $self->param($param, scalar 
$associated_object->param($case_map{$associated_object}{$param})), last OBJ
             if (exists($case_map{$associated_object}{$param}));
         }
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to