[Twisted-web] Nevow Templating question

Andy Gayton andy at thecablelounge.com
Tue Apr 13 00:08:31 MDT 2004


jonathan vanasco wrote:

> Can someone please offer their input?

The following is a bit more graphic designer friendly:

> template.html
> -------------------
> <tr>
>     <td valign="top"> pick a city</td>
>     <td>
>         <select name="city">
>         <span nevow:data="citiesList" nevow:render="city"></span>
>         </select>
>     </td>
> </tr>


<select name="city" nevow:data="citiesList" nevow:render="sequence">
	<option nevow:pattern="item" nevow:render="city" value="1">
	</option>
</select>


> testing.py
> -------------------
>     def data_citiesList(self, context, data):
>         return {"New York":'1', "Los Angeles":'2'}
>     def render_city(self, context, data):
>         """Example of using stan to render a page.
>         """
>         return rend.stan(
>             [
>                 T.option(value=v)[k] for (k,v) in data.items()
>             ]
>         )

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?

cheers,
Andy.



More information about the Twisted-web mailing list