[ZPT] Re: Problems with context and rendering and DTML and... a story of failure and puzzlement

Steve Spicklemire steve@spvi.com
Thu, 21 Jun 2001 19:53:56 -0500


OK.. this almost worked.. it turns out the tabs are supposed to be
horizontal ;-), but when I tried to do the 'repeat' in the same tag as
the 'define="index.. "', the template failed to render claiming it
couln't find 'tab' in 'repeat'. So.. I created a fake outer scope using
'span', but I don't think it's really kosher.. if you see what I mean:

<html>
  <head>
    <title tal:content="template/title">The title</title>
  </head>
  <body>
  <div metal:define-macro="tabDisplay">
	<table border="0"
             tal:define="activeTab python:request.get('activeTab', 0)">
	<tr><span tal:repeat="tab here/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></span>
	</tr>
    </table>
  </div>
 </body>
</html>


Is there any way to us <span> or <div> to create an outer scope (e.g.,
to set up a repeat) that doesn't actually end up rendering the tag, but
just the content?

thanks!
-steve

Evan Simpson wrote:
> 
> 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