Anyone has any experience with adding alternative template engines to tornado?
In particular I'm interested in emitting python code like template.py
already does
I'm interesting in getting mustache templating engine to work under
tornado ( http://mustache.github.com/ )
Anyone has any experience with adding alternative template engines to tornado?
In particular I'm interested in emitting python code like template.py
already does
But I just love the clean separation of code and logic, and the fact
that I can use the same templates within javascript
I'm entirely unclear on what you hoped to hear.
Regards,
Cliff
This is a project all in itself and may not actually make a lot of sense
for Moustache anyway. Based on my admittedly brief overview of the code,
it appears to do all of its analysis outside the template using regular
expressions. That is, there is no Python code inside the template to
compile. Tornado's default template engine actually allows embedding
of Python code inside the template, so it is a different beast
altogether.
In any case, even if pystache is somewhat slow, there are lots of ways
to work around this. If raw speed was the primary way to make a website
fast, then there would be exactly zero Ruby on Rails websites in
existence. But of course we know there are plenty, some of them with a
large amount of traffic.
For a lot of good ideas, I'd suggest reading this article:
http://kovyrin.net/2007/08/05/using-nginx-ssi-and-memcache-to-make-your-web-applications-faster/
Even just using the SSI trick will make a big improvement, since it can
drastically cut down the amount of HTML you have to generate
dynamically.
Bottom line is, if you like Moustache, then use it. Just use it wisely.
> ideally it would guess the template engine to use based on the file
> extension instead of hard coding
That's not really necessary. You can use any template engine you want
with Tornado. As Ben pointed out, you simply call whatever method the
engine provides to render a template. I use Breve with Tornado and it
requires no integration at all.
Regards,
Cliff