There is, somewhat intentionally, no way to insert HTML into the page without parsing; twisted.web.template
is a bit more of a stickler about producing correct output than nevow was.
There are a couple of ways around this.
- Ultimately, your HTML is going to some kind of output stream. You could simply insert a renderer that returns a pair of
Deferred
objects, and does a.write
to the underlying stream after the first one fires but before the second. Kind of gross, but it effectively expresses your intent :). - You can simply re-parse the output of epydoc into HTML using
XMLString
or similar, so thattwisted.web.template
can write it out correctly. This will "waste" a little bit of CPU, but in my opinion it will be worth it for (A) the stress-test it will give t.w.t and (B) the guarantee - presuming thatt.w.t
is correct - that it will give you that you're emitting valid HTML.
As I was writing this answer, however, I realized that point 2 isn't generally possible with arbitrary HTML with the current public API of twisted.web.template. Ideally, you could use html5lib
to parse this stuff, and then just dump the parsed input into your document tree.
If you don't mind mucking around with private API, you could probably hook up html5lib's SAX support to the internal SAX parser that we use to load templates.
Of course, the real solution is to fix the ticket you already filed, so you don't have to use private API outside of Twisted itself...