[Django]-Respond with latex code to web request with django

6👍

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.

2👍

You can use Jinja2, or maybe you can do that by using the default template system too:

Looking at the code for django/template/__init__.py, Around line 78 (Django 1.2) I saw this:

75 # template syntax constants
76 FILTER_SEPARATOR = '|'
77 FILTER_ARGUMENT_SEPARATOR = ':'
78 VARIABLE_ATTRIBUTE_SEPARATOR = '.'
79 BLOCK_TAG_START = '{%'
80 BLOCK_TAG_END = '%}'
81 VARIABLE_TAG_START = '{{'
82 VARIABLE_TAG_END = '}}'
83 COMMENT_TAG_START = '{#'
84 COMMENT_TAG_END = '#}'
85 SINGLE_BRACE_START = '{'
86 SINGLE_BRACE_END = '}'

So, there’s a chance that you can manage to replace that constants (for just a limited usage) with some custom ones..

Don’t monkeypatch directly, as changing that constants in that module would prevent default views from being rendered correctly.

Leave a comment