Jinja, also commonly referred to as "Jinja2" to specify the newest release version, is a Python template engine used to create HTML, XML or other markup formats that are returned to the user via an HTTP response.
Jinja2 is useful because it has consistent template tag syntax and the project is cleanly extracted as an independent open source project so it can be used as a dependency by other code libraries.
Jinja2 strikes a thoughtful balance on the template engine spectrum where on one end you can embed arbitrary code in the templates and the other end a developer can code whatever she wants.
The first recorded public released of Jinja2 was in 2008 with 2.0rc1. Since then the engine has seen numerous updates and remains under active development.
Jinja2 engine certainly wasn't the first template engine. In fact, Jinja2's syntax is inspired by Django's built-in template engine, which was released several years earlier. There were many template systems, such as JavaServer Pages (JSPs), that originated almost a decade before Jinja2. Jinja2 built upon the concepts of other template engines and today is widely used by the Python community.
Jinja2 is a commonly-used templating engine for web frameworks such as Flask, Bottle, Morepath and, as of its 1.8 update, optionally Django as well. Jinja2 is also used as a template language by configuration management tool Ansible and the static site generator Pelican, among many other similar tools.
The idea is that if a developer already knows Jinja2 from working with one project then the exact same syntax and style can be used in another project that requires templating. The re-use reduces the learning curve and saves the open source project author from having to reinvent a new templating style.
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 templates 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.
Python Templating Performance Showdown: Django vs Jinja puts together some benchmarks for how Django templates compare with Jinja templates. The usual benchmarking caveats apply here but there are some interesting tests that examine how the template engines handle large numbers of variables and other factors.
Universal Jinja presents a high-level overview of what you could do using the Jinja-like Nunchuks library to perform server-side template rendering for Django applications.