nevow - alternating row colors?
If I have a table, and I want the background colors to alternate, how would I do that in Nevow? __________________________________________________________________ Switch to Netscape Internet Service. As low as $9.95 a month -- Sign up today at http://isp.netscape.com/register Netscape. Just the Net You Need. New! Netscape Toolbar for Internet Explorer Search from anywhere on the Web and block those annoying pop-ups. Download now at http://channels.netscape.com/ns/search/install.jsp
On Aug 23, 2004, at 2:11 PM, angryhicKclown@netscape.net wrote:
If I have a table, and I want the background colors to alternate, how would I do that in Nevow?
You just supply multiple pattern nodes with the same name, and nevow will cycle through them when it is copying them. For example, if you are rendering a list of items in a table, you would supply more than one 'item' pattern node: <table nevow:render="sequence" nevow:data="whatever"> <tr nevow:pattern="item" style="background-color: blue"> ... </tr> <tr nevow:pattern="item" style="background-color: red"> ... </tr> </table> dp
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@netscape.net wrote:
If I have a table, and I want the background colors to alternate, how would I do that in Nevow?
On Mon, 2004-08-23 at 14:55 -0400, Phil Frost wrote:
One option is to use the :even and :odd (iirc) selectors of CSS.
I think it's nth-child(even) actually but that's a CSS3 selector and has little (if any) browser support yet. Cheers, Matt -- __ / \__ Matt Goodall, Pollenation Internet Ltd \__/ \ w: http://www.pollenation.net __/ \__/ e: matt@pollenation.net / \__/ \ t: +44 (0)113 2252500 \__/ \__/ / \ Any views expressed are my own and do not necessarily \__/ reflect the views of my employer.
Not strictly with Nevow, but it works nicely... http://www.alistapart.com/articles/zebratables/ Chris On Mon, 23 Aug 2004 14:11:00 -0400, angryhickclown@netscape.net <angryhickclown@netscape.net> wrote:
If I have a table, and I want the background colors to alternate, how would I do that in Nevow?
__________________________________________________________________ Switch to Netscape Internet Service. As low as $9.95 a month -- Sign up today at http://isp.netscape.com/register
Netscape. Just the Net You Need.
New! Netscape Toolbar for Internet Explorer Search from anywhere on the Web and block those annoying pop-ups. Download now at http://channels.netscape.com/ns/search/install.jsp
_______________________________________________ Twisted-web mailing list Twisted-web@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web
-- Still searching for an even prime > 2!
participants (5)
-
angryhicKclown@netscape.net
-
Chris Cioffi
-
Donovan Preston
-
Matt Goodall
-
Phil Frost