[Zope] Nested dtml-in loops (was: [Zope-dev] SQL-Output)

Dieter Maurer dieter@handshake.de
Thu, 6 Jul 2000 23:34:19 +0200 (CEST)


Andre Schubert writes:
 >  ... problem with names clashes from nested dtml-in loop ...

Your problem may be generalized:

<-- l1 and l2 are sequences -->

<dtml-in l1>
  <dtml-in l2>
    <-- here you need to access both components from both the
        inner and the outer dtml-in
	There may be a name clash between the two (implicite) loop variables
    -->
  </dtml-in l2>
</dtml-in l1>

You can use renaming to avoid any clashed.
I demonstrate it for "sequence-item".

<dtml-in l1>
  <dtml-let outer_lv=sequence-item <-- ATTENTION: calls it! -->
  >
    <dtml-in l2>
      ...
      <dtml-var outer_lv>	<-- the outer loop value -->
      <dtml-var sequence-item>  <-- the inner loop value -->
      ...
    </dtml-in l2>
  </dtml-let>
</dtml-in l1>


If you want to prevent the outer loop value to be called,
you may use "_.getitem('sequence-item')" rathen than just
sequence-item.


Dieter