Dynamic use of templates in Jinja2

后端 未结 1 1834
太阳男子
太阳男子 2020-12-23 21:49

I have to following scenario:

a python list of python dictionaries l = [a,b,c,...,n] each element of the list is a python dictionary that looks somethin

相关标签:
1条回答
  • 2020-12-23 22:17

    If anyone needs it:

    {% for d in dicts %}
      {% set template = d.type + '.html' %} {% include template %}
    {% endfor %}
    

    then in the template you can access the content like so:

    {{ d.content }}
    

    Thanks to donri from the #pocoo channel on freenode !

    0 讨论(0)
提交回复
热议问题