October 2018
Intermediate to advanced
332 pages
8h 9m
English
Jinja is a templating language written in Python. A templating language is a simple format that is designed to help automate the creation of documents. In any templating language, variables passed to the template replace predefined elements in the template. In Jinja, variable substitutions are defined by {{ }}. The {{ }} syntax is called a variable block. There are also control blocks defined by {% %} that declare language functions, such as loops or if statements. For example, when the Post model from Chapter 2, Creating Models with SQLAlchemy, is passed to it, we get the following Jinja code:
<h1>{{ post.title }}</h1>
This produces the following:
<h1>First Post</h1>
The variables displayed in a Jinja template can be any ...