FreeKB - Jinja Getting Started with Jinja
Getting Started with Jinja

Jinja is a library used with Python, thus you will first need to install Python on your system before using Jinja.

Often, pip is used to install Jinja. The pip list and pip show commands can be used to determine if Jinja is installed. Here is an example of what could be displayed by the pip list command when Jinja is installed.

~]$ pip3 list
Package                            Version
---------------------------------- ------------------
Jinja2                             2.11.2


If Jinja is not installed, the pip install command can be used to install Jinja.

pip3 install Jinja2


Since Jinja is a Python library, Jinja is often used in a Python script. Here is a basic example of how to create a variable ("name" in this example) and then how to use the Jinja templating system to print the value ("John Doe" in this example) in a Python script.

from jinja2 import Template

name = "John Doe"

template = Template("Hello {{ name }}")
message = template.render(name=name)



Add a Comment

We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.

Please enter 8b12a in the box below so that we can be sure you are a human.


Web design by yours truely - me, myself, and I   |   |