Chapter 3. Templates and Views
This chapter could alternatively be titled The Flask Chapter, because we will cover two of the most recognizable components of the framework: the Jinja2 template language, and the URL routing framework. Up to this point, we have been laying the foundation for the blog app, but we have barely scratched the surface of actual Flask development. In this chapter, we will dive into Flask and see our app finally start taking shape. We will turn our drab database models into dynamically rendered HTML pages, using templates. We will come up with a URL scheme that reflects the ways we wish to organize our blog entries. As we progress through the chapter, our blog app will start looking like a proper website.
In this chapter we shall:
- Learn how to render HTML templates using Jinja2
- Learn how to use loops, control structures, and the filters provided by the Jinja2 template language
- Use template inheritance to eliminate repetitive coding
- Create a clean URL scheme...