[Twisted-web] Alternative to <nevow:attr>
andrew-twisted at puzzling.org
Tue Oct 19 03:51:48 MDT 2004
On Tue, Oct 19, 2004 at 12:42:46AM -0700, David Reid wrote:
> Which is horrendously ugly and difficult to explain to pretty much
> anyone. Now, there are plenty of other solutions to this problem, but
> none of them provide the flexability for the template author as
> <nevow:attr> and <nevow:slot> do.
> For instance:
> <nevow:attr name="href">
> /users/<nevow:slot name="username" />/images
> </ nevow:attr>
> Works perfectly well. Which according to fzZzy is the main reason for
> choosing this syntax.
> A comparison to this with the syntax of TAL was recently mentioned on
> the ML (Comparison with ZPT [Was: [Twisted-web] Sub-tag level templating
> in Nevow: possible?]), and the TAL syntax seems to be cleaner, though
> I'm not sure if it provides the above functionality. While discussing
TAL does allow this, in two ways (that I know of):
First, there's the hackish way:
<a tal:attributes="href python:'/users/' + context/username + '/images'"
The second way is to put this sort of complex code a view:
def __init__(self, context, request):
self.context = context
self.request = request
return '/users/' + self.context.username + '/images'
then you can do:
<a tal:attributes="href view/imagesPath" />
More information about the Twisted-web