> > I want to generate HTML output like this: > > > > <p>item1<br/> > > item2<br/> > > ... > > itemX</p> > > > > item1..itemX are either plain text strings or they are contained > > widgets. It is trivial to manually generate text like this, but I want > > to do it the idiomatic, widgets-way. My requirement for the solution > > is that it must not be much more complex than this: > > > > def list_items_to_html(items): > > return "<p>" + "<br/>".join(render(item) for item in items) + "</p>" > > Untested, but it is essentially: > > class ExampleWidget(Widget): > params = ["items"] > > template = """ > <p py:content="'<br/>'.join(render(item) for item in items)"> > </p> > """ > > example_widget = ExampleWidget()
Nope: 1. You forgot the xmlns:py="http://purl.org/kid/ns#" thingy 2. Since the items-list may contain both widgets and strings you need to declare that in the member_widgets class variable. 3. py:content="'<br/>'.join(render(item) for item in items)" replaces the <p>-tag with a textstring (I think), "foo<br/>bar<br/>". Kid doesn't like that, so you get: xml.parsers.expat.ExpatError: not well-formed (invalid token): line 3, column 23 -- mvh Björn --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "TurboGears" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears -~----------~----~----~----~------~----~------~--~---

