Skip to main content

3 docs tagged with "templates"

View all tags

Templates in Flask (Part 1): Template Inheritance

We've learned how to use Flask's render_template() function to serve HTML files and pass variables to them. This is great, but as you build a website with multiple pages, you'll notice that a lot of your HTML is repetitive. The navigation bar, the footer, the `` section with all your CSS links—these are the same on every page.

Templates in Flask (Part 2): Control Structures and Filters

We've learned how to render templates and pass variables from our Flask application to our HTML. Now, let's unlock the true power of the Jinja2 templating engine by exploring two of its most important features: control structures and filters.

Your First Flask App (Part 2): Templates and Jinja2

In the last article, we created our first Flask application, but our view function returned a simple string of HTML. This is not practical for building real websites. A real website has complex HTML, and we need a way to keep our Python logic separate from the presentation markup.