Explore Flask

8.6. Summary

  • Use Jinja for templating.
  • Jinja has two kinds of delimeters: {% ... %} and {{ ... }}. The first one is used to execute statements such as for-loops or assign values, the latter prints the result of the contained expression to the template.
  • Templates should go in myapp/templates/ — i.e. a directory inside of the application package.
  • I recommend that the structure of the templates/ directory mirror the URL structure of the app.
  • You should have a top-level layout.html in myapp/templates as well as one for each section of the site. The former extend the latter.
  • Macros are like functions made-up of template code.
  • Filters are functions made-up of Python code and used in templates.