[ZPT] changing the order of operations
Jamie Heilman
jamie at audible.transient.net
Thu Jul 24 15:15:30 EDT 2003
Charlie Clark wrote:
> On 2003-07-24 at 08:50:58 [+0200], Jamie Heilman wrote:
> > You want to itterate over a set of items wrapping some in a tag with
> > attributes, and some not, based upon external criteria. Here's bad
> > example (isPrincipiaFolderish is sick, and <a> is probably not the most
> > useful tag), but a self-contained example at any rate: <ul>
> > <li tal:repeat="o here/objectValues"><a
> > tal:define="name o/getId"
> > tal:content="string:>${name}<"
> > tal:attributes="href string:${o/absolute_url}/;id o/getId"
> > tal:omit-tag="not:o/isPrincipiaFolderish">objects</a></li>
> > </ul>
>
> If I understand this correctly, the link should be omitted if
> o.isPrincipiaFolderish() is not true? Wouldn't this be better just setting
> a tal:condition or I am missing something in my lack of deep Zope knowledge?
tal:condition would remove the content entirely, and thats not what's
desired in this case. Patch to my own stupid example, because I
defined 'name' for a reason and then forgot to take advantage of it:
- tal:attributes="href string:${o/absolute_url}/;id o/getId"
+ tal:attributes="href string:${o/absolute_url}/;id name"
Not that it matters, but it bugs me to see that inefficiency. Another
minor note, isPrincipiaFolderish is a simple attribute, not a method,
which is why I don't suggest using it, like I said, its a bad example,
but self-contained.
I haven't really rolled around in the TAL code yet so I'm not sure
where "order" is defined (I'm guessing I'd be insanely lucky if it
were really that simple). If somebody knows the general area I should
start poking in to play with this change, let me know. Presumebly the
patch to check for the degenerate case of attributes and omit-tag=""
together would be in a related area and I could make that change too.
--
Jamie Heilman http://audible.transient.net/~jamie/
"I was in love once -- a Sinclair ZX-81. People said, "No, Holly, she's
not for you." She was cheap, she was stupid and she wouldn't load
-- well, not for me, anyway." -Holly
More information about the ZPT
mailing list