It is rather sketchy still, but I’ve just put up a little idea about a way to avoid doing template languages at all, and
embedding HTML into Python code directly instead.
It is called NonTemplate. Let me know what you think!
UPDATE: Some vague performance figures, using the same very simple benchmark as the previous template language performance comparison posts.
These figures are running on Python 2.6.5, on a linux laptop (x64) with output to /dev/null …
print: 1.612
Mako: 1.756
Jinja: 10.803
nontemplate: 18.198
django: 42.212
SimpleTAL: 59.024
genshi: 81.460
… mako is very very clearly the winner here … its code generation is head-and-shoulders above the rest, producing pretty much
exactly the same code as you’d get if you wrote a whole lot of “print” statements yourself. Nontemplate is stuck in the middle … unfortunately, all the ‘with’ shenanigans turns out to be pretty slow. On the other hand, it is still a lot quicker than Django templates, SimpleTAL or Genshi, and a lot smaller than any of them, so I guess it is not all bad news.
Posted by nickzoic