Jinja，又常称为”Jinja2” ，是一种Python模板引擎，根据用户的HTTP请求生成HTML，XML 或其他格式输出。
Jinja2 有一套清晰的模板标记语法，并能作为其他应用使用，参见an independent open source project。
- Real Python has a nice Jinja2 primer with many code examples to show how to use the template engine.
- The second part of the Flask mega tutorial is all about Jinja2 templates. It walks through control flow, template inheritance and other standard features of the engine.
- Upgrading to Jinja2 Templates in Django 1.8 With Admin shows how to fix an issue that can occur with Django 1.8 and using Jinja2 as the template engine.
- The official Jinja2 template designer documentation is exceptionally useful both as a reference as well as a full read-through to understand how to properly work with template tags.
- When you want to use Jinja2 outside of a web framework or other existing tool, here’s a handy quick load function snippet so the template engine can be easily used from a script or the REPL.
- When working with Jinja2 in combination with LaTeX, some of Jinja2’s blocks can conflict with LaTeX commands. Check out this post on LaTeX templates with Python and Jinja2 to generate PDFs to resolve those issues.
- When you use Jinja2 for long enough, eventually you’ll want to escape large blocks of Jinja2-like text in your templates. To do so, you’ll need the “raw” template tag.