I am new to python for web apps, and am using django for my first try. Since the app should create some latex files dynamically, I thought that the most elegant way would be to return the latex file as a web request and create the contents dynamically using the django template engine. However, the template syntax consists of characters ({, % and }) that are special characters in latex, too. So in this special case, I would want to change the syntax of the django template system.
My questions are:
- Do you think this is the recommended way to do latex file creation? Or should I open the template files using python and just create regexps for all the variables and so on. (I would really prefer the django template way!)
- How can I change the way variables and functions are substituted in django templates? E.g. {{ x }} to << x >> or anything like that.
AFAIK, the Django template language doesn’t allow for custom syntaxes. Fortunately, there’s another pluggable templating system called Jinja2 that does.
See this blog post for someone else’s experience with LaTeX and Jinja2.
Official Jinja2 docs on the subject.