Templating with Jinja
This chapter will cover the basics of Jinja templating from the perspective of Flask. We will also learn how to design and develop applications with modular and extensible templates.
Information
If you have followed Flask or Jinja or this book’s previous editions, you might have noticed that, previously, this templating library was called Jinja2. The latest version of Jinja at the time of writing is version 3, and the authors/community have decided to call it just Jinja instead of confusingly continuing with Jinja2, Jinja3, and so on.
In Flask, we can write a complete web application without the need for a third-party templating engine. For example, have a look at the following code; this is a standalone, simple Hello World application with a bit of HTML styling included:
from flask import Flask app = Flask(__name__) @app.route('/') @app.route('/hello') @app.route('/hello/<user>') def hello_world(user=None...