steder/txtemplate — pull request #4 by harbulot (2014-11-15 18:09:39+00:00)
Title: Genshi options

Hi,

I've made a couple of minor modifications when using txtemplate with Genshi.

Firstly, I've added a `serialize_method` to the `GenshiTemplateAdapter` class. This allows you to choose between [`xml`, `xhtml`, `html` and `text`](http://genshi.edgewall.org/wiki/Documentation/streams.html#serialization-methods). When nothing is specified, the default was `xml`, which can cause problems with some web browsers (e.g. an empty title would generate `

` using `xml`, which the browser would see as an unclosed `

` in HTML, but it generates `<title>

` using `html`). I've set the default here to be `html`, but this can be changed for each instance.

Secondly, I've passed all the other options from `genshi.template.loader.TemplateLoader.__init__` to `txtemplate.templates.GenshiTemplateLoader.__init__`, keeping the default as they were. This allows you to change some settings, such as `variable_lookup='lenient'` instead of `variable_lookup='strict'`. While there could have been a workaround by setting `adapter.template.lookup='lenient'` (on the `adapter` instance), this didn't seem to work when using other included templates (they would be loaded using a `strict` lookup anyway).

If this is of interest, feel free to integrate these changes back into the main project.