Lably
Skip to content

Jinja (template engine)

Web template engine for Python

  • 4 min read
  • 3 chapters

Related on Lably

Through Python (programming language), Sandbox (computer security) and Conditional (computer programming)

The Jinja template engine allows customization of tags, filters (for formatting or transforming values), tests (for evaluating conditions), and globals. Also, unlike the Django template engine, Jinja allows the template designer to call functions with arguments on objects. Jinja is the default template engine for Flask, as well as Home Assistant's Automations. It is also used by Ansible, Trac, and Salt. It is also used to make SQL macros, for example for use with dbt.

Features

Some of the features of Jinja are:

  • sandboxed execution
  • automatic HTML escaping to prevent cross-site scripting (XSS) attacks
  • template inheritance
  • compiles down to the optimal Python code just-in-time
  • optional ahead-of-time template compilation
  • easy to debug (for example, line numbers of exceptions directly point to the correct line in the template)
  • configurable syntax

Jinja, like Smarty, also ships with an easy-to-use filter system similar to the Unix pipeline.

Sign in to keep reading

2 more chapters are free with a Lably account.

More in Computing and communication