Block composition and layout inheritance
Usually, any web application will have a number of web pages that will be different from each other. Code blocks such as headers and footers will be the same in almost all the pages throughout the site. Likewise, the menu also remains the same. In fact, usually, just the center container block changes, and the rest usually remains the same. For this, Jinja2 provides a great way of inheritance among templates.
It's a good practice to have a base template where we can structure the basic layout of the site along with the header and footer.
Getting ready
In this recipe, we will try to create a small application where we will have a home page and a product page (such as the ones we see on e-commerce stores). We ...
Get Flask Framework Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.