Streaming templating languages for use as WSGI body.
Alice Bevan–McGregor
alice at gothcandy.com
Wed Jan 5 20:36:31 EST 2011
Not sure if it's bad form to respond to your own posts, but here goes. ;)
Coding up a quick hack of a templating engine, I've produced this:
> http://pastie.textmate.org/private/ws5jbeh1xyeaqtrhahevqw
(The implementation of the engine itself is a base class that overrides
__call__ and __getitem__, with __unicode__ serializing in one block,
the norm for templating engines, and .render(encoding='ascii')
returning a generator using cStringIO for internal buffering.)
I even have a light-weight widget system based on it, now. E.g.
> class Input(Widget):
> type_ = None
>
> @property
> def template(self):
> return tag.input (
> type_ = self.type_,
> name = self.name,
> id = self.name + '-field',
> value = self.value,
> **self.args
> )
I'll polish it and package it up. :)
- Alice.
More information about the Python-list
mailing list