A normal jinja2 include looks like {% include 'directory/filename.html' %}
but I am looking to do something like `{% include 'dropins/*.html' % where obviously the order would be alphabetically.
Is this possible? How?
Use the jinja2 {% include %} directive. This will include the content from the correct content-file. Show activity on this post. You can use the include statement.
Context contains the dynamic content that you want to inject in your template when it is being rendered.
You could pass a list of file names, then iterate over them:
{% for file_name in file_list %}
{% include file_name %}
{% endfor %}
And of course, inside file_list you should have already built your list of file names
file_list = ['dropins/file1.html', 'dropins/file2.html']
In Python, I would write some function that could discover all files inside that directory and then save their filenames to the list... or if you know the list just hard code them like above
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