base.html 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. {# ``base.html`` is the template all our other templates derive from. While
  2. Flask-Bootstrap ships with its own base, it is good form to create a custom
  3. one for our app, as it allows customizing some aspects.
  4. Deriving from bootstap/base.html gives us a basic page scaffoling.
  5. You can find additional information about template inheritance at
  6. http://jinja.pocoo.org/docs/templates/#template-inheritance
  7. #}
  8. {%- extends "bootstrap/base.html" %}
  9. {# We also set a default title, usually because we might forget to set one.
  10. In our sample app, we will most likely just opt not to change it #}
  11. {% block title %}Sample App for Flask-Bootstrap{% endblock %}
  12. {# While we are at it, we also enable fixes for legacy browsers. First we
  13. import the necessary macros: #}
  14. {% import "bootstrap/fixes.html" as fixes %}
  15. {# Then, inside the head block, we apply these. To not replace the header,
  16. ``super()`` is used: #}
  17. {% block head %}
  18. {{super()}}
  19. {#- Docs: http://pythonhosted.org/Flask-Bootstrap/macros.html#fixes
  20. The sample application already contains the required static files. #}
  21. {{fixes.ie8()}}
  22. {%- endblock %}
  23. {# Adding our own CSS files is also done here. Check the documentation at
  24. http://pythonhosted.org/Flask-Bootstrap/basic-usage.html#available-blocks
  25. for an overview. #}
  26. {% block styles -%}
  27. {{super()}} {# do not forget to call super or Bootstrap's own stylesheets
  28. will disappear! #}
  29. <link rel="stylesheet" type="text/css"
  30. href="{{url_for('static', filename='sample-app.css')}}">
  31. {% endblock %}
  32. {# Finally, round things out with navigation #}
  33. {% block navbar %}
  34. {{nav.frontend_top.render()}}
  35. {% endblock %}