Skip to Content
Mastering Flask Web Development - Second Edition
book

Mastering Flask Web Development - Second Edition

by Daniel Gaspar, Jack Stouffer
October 2018
Intermediate to advanced
332 pages
8h 9m
English
Packt Publishing
Content preview from Mastering Flask Web Development - Second Edition

Jinja's syntax

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 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Flask Web Development, 2nd Edition

Flask Web Development, 2nd Edition

Miguel Grinberg
Flask Web Development

Flask Web Development

Miguel Grinberg

Publisher Resources

ISBN: 9781788995405Supplemental Content