Reputation: 101
Consider I have the below multi-dimensional list which I would like to display in Flask HTML Page.
Sample List
list_html = [['Mun--CEO--Bank', 'Chee--CEO--Trust'], ['Miloš--Researcher--College'], ['Mun--CEO--Bank']]
I am trying to display this list in Flask Webpage. Where each item in list is displayed in the next line (please refer the expected output)
Sample Code
{% for dat in list_html %}
<div><span></span><ul><li> {{data[dat]}} </li></ul></div>
{% endfor %}
Here, the data refers to the list_html which I pass it in render_template.
I am unable to display each item as a new line in the output HTML page.
Expected Output
* Mun--CEO--Bank
* Chee-CEO-Trust
* Miloš--Researcher--College
* Mun--CEO--Bank
Upvotes: 0
Views: 404
Reputation: 6027
You just need a nested for loop. Something like this:
{% for dat in list_html %}
<div>
<span></span>
<ul>
{% for d in dat %}
<li> {{ d }} </li>
{% endfor %}
</ul>
</div>
<br>
{% endfor %}
Hope this helps. Good luck.
Upvotes: 2