Ben discovered two problems with using ElementTree for the WebHelpers
HTML generation:

- It outputs only XHTML, not HTML.

- You can't call str() on an element and get the serialized version,
you have to call .write().  While a Mako filter can be taught to do
that, it makes it less usable in other contexts.

One solution would be to make a wrapper that serializes on str(), and
just live with XHTML even if the page is HTML.

I looked at BeautifulSoup, but it's really a parsing/query tool than a
generator.  There's only one serializing method, and who knows how it
decides whether to output <br /> or <br>.

Or we could write our own dual-mode serializer.

Or use Genshi, which outputs both XHTML and HTML. But Genshi requires
a complete XM document for input , and we're just generating snippets.

Or borrow the serializing code from Genshi and use it with ElementTree.

Or use one of the stan/nevow/breve type generators.

    doc = T.div[
        T.h1['Section ', results['secnum']],
        T.p['Elements of type ', results['type'],
            ' should be coloured ', results['color']],
        T.p['Contributed by: ', results['user']],
        ]

Any better ideas?  Is there a tokenizing XHTML/HTML generator that's
pythonic and doesn't depend on C libraries?

-- 
Mike Orr <[EMAIL PROTECTED]>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" 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/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to