[Twisted-web] nevow substitute into html attributes?
Matt Goodall
matt at pollenation.net
Fri Jul 9 08:31:50 MDT 2004
On Fri, 2004-07-09 at 15:15, Jeff Bowden wrote:
> Matt Goodall wrote:
>
> >On Thu, 2004-07-08 at 17:44 -0600, Jason Mobarak wrote:
> >
> >
> >>In Nevow's SVN take a look at Nevow/sandbox/mg/attr.tac
> >>
> >>
> >
> >Although ... the "official" way is as follows (leaving out anything not
> >directly related to the <a>):
> >
> >
>
> Interesting. What makes this "official"? Is it documented somewhere?
By "official", I merely meant that <nevow:attr> works out of the box -
it uses the facilities provided by the nevow package and no more.
attr.tac is just one example of how a custom renderer often makes code
simpler and therefor more readable.
Cheers, Matt
> ><a href="???"><nevow:attr name="href"><nevow:slot name="linkURL"/></
> >nevow:attr><nevow:slot name="linkTitle">Link Title</nevow:slot></a>
> >
> >The mapping renderer on your <li> will fill the 'linkURL' (and
> >'linkTitle') slot. The <nevow:attr> will then alter the href attribute
> >of the <a>.
> >
> >But I prefer the attr.tac way, it's not so ugly ;-).
> >
> >Cheers, Matt
> >
> >
> >
> >>On Thu, 08 Jul 2004 16:12:24 -0700, Jeff Bowden
> >><jlb at houseofdistraction.com> wrote:
> >>
> >>
> >>>Nevow slots seem to be limited to replacing whole elements. Is there
> >>>any way to have a slot which is an attribute or a value of an attribute?
> >>>
> >>>For one example, I want to render a list of mappings that looks like this:
> >>>
> >>> list_of_links = [
> >>> { 'linkTitle': 'Big Fun Site', 'linkURL':
> >>> 'http://bigfunsite.com/funfunfun/index.html'},
> >>> { 'linkTitle': 'Not Quite As Much Fun Site', 'linkURL':
> >>> 'http://mediocre.com/its_ok.html'},
> >>> ]
> >>>
> >>>So I need an html template:
> >>>
> >>> <ul nevow:data="list_of_links" nevow:render="sequence">
> >>> <li nevow:pattern="item" nevow:render="mapping">
> >>> <a href="???"><nevow:slot name="linkTitle">Link
> >>> Title</nevow:slot></a>
> >>> </li>
> >>> </ul>
> >>>
> >>>So the link title is taken care of but what do I put instead of '???' to
> >>>get the href to contain the value of linkURL for the item?
> >>>
> >>>
>
>
> _______________________________________________
> Twisted-web mailing list
> Twisted-web at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web
--
__
/ \__ Matt Goodall, Pollenation Internet Ltd
\__/ \ w: http://www.pollenation.net
__/ \__/ e: matt at pollenation.net
/ \__/ \ t: +44 (0)113 2252500
\__/ \__/
/ \ Any views expressed are my own and do not necessarily
\__/ reflect the views of my employer.
More information about the Twisted-web
mailing list