Jinja2 is very similar to DTL in syntax. But it has a slightly different philosophy in certain places. For instance, in DTL the method call is implied as in the following example:
{% for post in user.public_posts %} ... {% endfor %}
But in Jinja2, we invoke the public_posts method similar to a Python function call:
{% for post in user.public_posts() %} ... {% endfor %}
This means that in Jinja2 you can call functions with arguments, unlike DTL. Refer to the Jinja2 documentation for more such subtle differences.
Jinja2 is usually chosen for the following reasons:
- Familiarity: If your template designers are already comfortable using Jinja2
- Whitespace control: Jinja2 has finer control over whitespace after the tags get rendered
- Customizability: Most aspects of Jinja2, from string defining markup to extensions, can be easily configured
- Performance: Some benchmarks...