[Twisted-web] nevow - alternating row colors?

Phil Frost indigo at bitglue.com
Mon Aug 23 12:55:38 MDT 2004


One option is to use the :even and :odd (iirc) selectors of CSS.

Another way is to have multiple patterns with the same name; the
coresponding patternGenerator will then alternate between them. For
example, if you have this template:

<table n:render='fu'>
  <tr n:pattern='item'><td>111</td></tr>
  <tr n:pattern='item'><td>222</td></tr>
</table>

and this code:

def render_fu(self, context, data):
  pattern = context.patternGenerator('item')
  content = [pattern() for _ in xrange(4)]
  return context.tag.clear()[content]

you will get a table

111
222
111
222

render_sequence is a builtin renderer that works like this already. If
you have some data in a sequence and each one outputs a row,
render_sequence is probably what you want. The docstring is in rend.py;
you can pydoc nevow.rend.sequence to see it.

On Mon, Aug 23, 2004 at 02:11:00PM -0400, angryhicKclown at netscape.net wrote:
> If I have a table, and I want the background colors to alternate, how
> would I do that in Nevow?



More information about the Twisted-web mailing list