Say I have a template layout saved in template.html. This template includes a banner, side navigation, content container, and footer. Can I use flask to break up these page elements in such a way that I can have files such as banner.html, sidenavigation.html, etc. and render these different files within template.html?
By default, Flask uses Jinja2 as its template engine.
Make sure you have activated your environment and have Flask installed, and then you can start building your application. The first step is to display a message that greets visitors on the index page. You'll use Flask's render_template() helper function to serve an HTML template as the response.
Simply store all your main code, back end code in app.py. Then all the layout arrangement, template code is in templates. Then inside the templates folder store the html files.
From: http://jinja.pocoo.org/docs/templates/#include
template.html
{% include 'banner.html' %} {% include 'sidenavigation.html' %} {% include 'content.html' %} {% include 'footer.html' %}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With