[Twisted-web] Nevow Templating question

Stephen Thorne stephen at thorne.id.au
Tue Apr 13 00:54:38 MDT 2004


On Tue, Apr 13, 2004 at 04:08:31PM +1000, Andy Gayton wrote:
> def data_citiesList(self, context, data):
>     return {"New York":'1', "Los Angeles":'2'}.items()
> 
> def render_city(self, context, data):
>     return context.tag(value=data[1])[data[0]]
> 
> 
> The only problem with the above is if you put something inside the 
> option for the template, say:
> 
> <option nevow:pattern="item" nevow:render="city" value="1">
> ned
> </option>
> 
> You will see ned prepended in each option rendered by nevow.  Does 
> anyone know how to overwrite the template contents of the option?

def render_city(self, context, data):
    return context.tag.clear()(value=data[1])[data[0]]

.clear() returns self, so you can chain it like that.

Stephen.




More information about the Twisted-web mailing list