Learning Jinja2: Part 1: Installing and Using

Learning Jinja2

Jinja2 is a template engine for Python featuring an optional sandbox environment.


Jinja2 is one of many packages available via PIP.

pip install jinja2

Note: Some environments and platforms like Heroku have different installation methods for packages. Consult the documentation of web services and online platforms for their instructions.


Once installed, Jinja2 can accessed through the normal package methods of the using the fromimport.

The Template() function loads some texts that contains text containing symbols to be changed during rendering. Once created, the render() function converts (interpolates) text based on variable and other names into their values.

Play with the example on Repl.it!