Flask-Bootstrap does not have a footer
block by default. The way of implementing one is covered in the FAQ
but I think this is fairly misleading.
From the example given, it is suggested that a new template should be created as base-with-footer.html
, like:
{% extends "bootstrap/base.html" %}
{%- block content %}
{{super()}}
{%- block footer %}
<footer>© 2016 Awesome, Inc.</footer>
{%- endblock footer %}
{%- endblock content %}
Any time you want to extend from the base-with-footer.html
, you'll have to call super()
inside the content
block. This is ugly and beats DRY.
I suggest a different approach: use footer
outside the content
block.
For the template in my_custom_blueprint/my_base.html
{% extends "bootstrap/base.html" %}
{# stuff happens here, like overrides of the original template in https://github.com/mbr/flask-bootstrap/blob/master/flask_bootstrap/templates/bootstrap/base.html #}
{% block content %}<p>Hello World!</p>{%- endblock content %}
{% block footer %}{%- endblock footer %}
Now in my_base_with_footer.html
{% extends "my_custom_blueprint/my_base.html" %}
{% block footer %}<p>Here goes your footer!</p>{%- endblock footer %}
With this approach you can reuse any of the blocks from the base without having to call super()
each time you need to write in contents
. You just have to extend from the template with the footer.
Hey thanks for sharing and commenting! I don't remember the specifics but I also remember that this was something that could be improved on.