[Zope] Embedding absolute_url in TAL Syntax
Dan Shafer
pydan@danshafer.com
Fri, 07 Jun 2002 10:08:28 -0700
Chris....
Thanks for the feedback and the input. I always learn a lot from you.
At 12:21 PM 6/7/2002 +0100, Chris Withers wrote:
>Dan Shafer wrote:
> >
> > OK, now that I have my table of objects produced by a Python script working
> > in ZPT, I need to figure out how to connect an entry in the table to its
> > URL. What is the TAL equivalent of:
> >
> > <td><a href="<dtml-var absolute_url>"><dtml-var title></a></td>
> >
> > It *seemed* like I should be able to code:
> >
> > <td><a
> > href="tal:content='item/absolute_url'"><tal:content="item/title"></a></td>
>
>Ick! This is _all_ wrong ;-)
Yeah, that's why it didn't work! :-(
>You want:
>
><td><a href="dummy" tal:attributes="href item/absolute_url"
> tal:content="item/title">Dummy Title</a></td>
Good stuff. This approach works nicely for the all-TAL approach. See my
other message for how I solved this when I'm passing the item in via a
Python script that generates a dictionary. All I had to do was grab the
absolute_url() in the Python script and stuff it into the dictionary and it
worked like a charm.
>In addition:
>
><tal:content="item/title">
>
>...is very wrong ;-)
>
>If you want to do it like that, you need:
>
><tal:x replace="item/title" />
OK, Chris, I'll take your word that my approach was "very wrong" (even with
the winkie). But that is precisely what is taught in Evan Simpson's basic
ZPT tutorial. Note that I didn't have an opening angle bracket so that the
tal: became the tag. (My understanding is that won't work, that tal: always
has to be an attribute of a known HTML tag, right?)
So if you have the time and inclination, could you explain further why
tal:content="item/title" is inferior to "tal:x replace="item/title" />? Is
it just that the latter approach *does* use a tal: tag rather than an
attribute of another tag? Or is there something more important lurking
there? The tutorial uses replace and content seemingly interchangeably, or
at least doesn't explain the difference very clearly or prominently.
>cheers,
>
>Chris
Dan Shafer, Chief Scribe and Tablet Keeper
PythonCard Open Source Project
http://pythoncard.sourceforge.net