On 8/18/06, BJörn Lindqvist <[EMAIL PROTECTED]> wrote:
>
> > Unless I'm very, very mistaken, with widgets, you can pass in any
> > parameters you want, do things with those values, then render them as
> > html.  What more could you want?
> >
> > I can't think of anything of the top of my head that you couldn't do
> > with a widget if you pass in the right parameters.
>
> 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()

A big plus for me is that, as I am planning to later add some flashy
AJAX  stuff in, when that time comes I can just pop the jaavscript
into my widget, change the template slightly, and it all still works
fine.

Ed

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to