[ZPT] Re: Problems with context and rendering and DTML and... a story of failure and puzzlement
   
    Evan Simpson
     
    evan@digicool.com
       
    Thu, 21 Jun 2001 17:42:42 -0400
    
    
  
steve wrote:
> <dtml-call "REQUEST.set('activeTab',REQUEST.get('activeTab',0))">
> <table border="0">
> <tr>
> <dtml-in tabList>
> <dtml-if "_['sequence-index']==activeTab">
> <td align="center" width=97 height=19 background="frontTab.gif"><a href="&dtml-target;">&dtml-label;</a></td>
> <dtml-else>
> <td align="center" width=97 height=19 background="backTab.gif"><a href="&dtml-target;">&dtml-label;</a></td>
> </dtml-if>
> </dtml-in>
> </tr>
> </table>
<table border="0"
        tal:define="activeTab python:request.get('activeTab', 0)">
<tr tal:repeat="tab tabList">
<td align="center" width=97 height=19 background="frontTab.gif"
     tal:define="index repeat/tab/index"
     tal:attributes="background python:test(index==activeTab,
       'frontTab.gif', 'backTab.gif')">
   <a href="/" tal:attributes="href tab/target"
               tal:content="tab/label">Label</a></td>
</tr>
</table>
 
> Specifically.. is there anything like 'sequence-index' in ZPT?
See the documentation for the repeat variable, (newly) located at:
http://dev.zope.org/Wikis/DevSite/Projects/ZPT/RepeatVariable
>>What does 'container' mean? I expected it meant the container of the
>>template that defined the macro. Anyway... I decided that
>>'here/Structures/biopsyTypes should work in both places
All TAL expressions get executed after all macros have been completely 
expanded, and they don't know anything about the macros' environment. 
That's why they're *macros*, not method calls.  So 'container' in or out 
of a macro always refers to the container of the currently executing 
template.  I'm not sure that there's a clean way to do what you 
intended, right now.
Cheers,
Evan @ digicool