Closure Templates (Soy) for Python
For the past two weeks I've been adding a Python backend to Google's Closure Templates. The work is now almost finished, so I'm happy to release a preview version of the Soy-to-Python compiler with a runtime Python library (closure-templates-for-python) and a Flask extension (Flask-Soy), to make it possible to work with Soy templates from Python.
All of this code is just recently finished without any real-world use, so there will be problems. I'm releasing it because I consider it functionally complete and I'm now actually planning to start using it in a Python project, which will hopefully help finding those problems. If you find any of them, please do let me know.
Some of the advantages of Soy templates are:
- The syntax suggests small, modular and well-documented templates.
- Smart contextual auto-escaping.
One big disadvantage of Soy templates is that you need to run Java in order to compile your templates, but on the plus side you can pre-compile them, so you don't necessarily need Java on your production servers.
Note: It seems that even though the Closure Templates project has some code publicly available, it is mostly developed internally and there also seems to be nobody at Google responsible for the open source project at the moment, so I have no hope for this code being accepted upstream. For that reason I tried to minimize changes to the code base, to be able to maintain it as a "fork", so the Python backend is not integrated with the rest of the code base as nicely as I'd like to. Just a warning if you want to have a look. :)