In TurboGears, we're on the verge of releasing version 1.1 where Kid has
been replaced with Genshi as the default templating engine.
TurboGears 1.x is using the Buffet API, and we're facing one serious
problem here when making the switch to Genshi, namely that it's
impossible to produce different doctype on different pages, e.g. when
you have part of your application that uses HTML, and a different part
that uses XHTML, or some pages using framesets or quirks mode.
The problem is that the doctype can only be passed to the buffet plugin
as an option at startup time, but at render time you can't overwrite
options any more, you can only overwrite the "format" (which corresponds
to Genshi's "method" parameter). If you set up the plugin with "html" as
the default method, and a html doctype, though you can later render
templates with an "xhtml" method, they still get the wrong html doctype.
We did not have this problem with Kid, since you can pass a doctype by
specifying e.g. "html-frameset", or "xhtml-strict" as the Buffet format
parameter; the format name in Kid always indirectly determines the
doctype as well. In Genshi however, you can only pass "html" or "xhtml"
here, and the doctype is chosen separately beforehand.
Also, in Kid you can pass serializer instances in the Buffet format
parameter, which have a suiting doctype already set, but in Genshi, you
can pass only serializer *classes* which are later initialized with the
default doctype that the plugin has been initialized with.
Here are some ideas how this problem could be solved in Genshi:
1) Let all serializer classes have their own default doctypes which will
be used when initialized with no doctype or an incompatible doctype.
2) Allow not only the names 'html', 'xhtml', 'xml', 'text' as rendering
methods, but also all names of doctypes such as 'html-transitional',
'html-frameset' etc. to specify method plus doctype in one parameter.
3) Add a parameter "options" to the Buffet API render method allowing to
overwrite any default parameters (particularly, the doctype parameter)
at rendering time.
Let me know how you think about this or if there are any better ideas.
-- Christoph