If on most pages in the website I have a list of categories or recent articles that are loaded from the DB - how can I avoid duplicating code using flask and jinja2 ?
The way it is now, I have an html file which I include like :
{% include '/root/latest_articles.html' %}
And then every view has to pass the parameter (list of articles) to the template. I'd like to avoid this.
What's the best way to achieve this in Flask?
Thanks.
Edit
The "additional template context" would work .. I could export a function that loads the data from the DB and access it in the "latest_articles.html" template.
Is there another way ?