I am attempting to loop through a list of dictionaries, using the values of the keys as HTML attributes within the jinja template. But the template doesn't render any of the data. I've verified the data is correct when I pass it in to the render_template function in the routes file.
I've gone through a number of StackOverflow questions, notably How to iterate through a list of dictionaries in jinja template? but to no avail.
Here's my data structure:
[
{
'name': 'chicken pie',
'image': 'chicken.jpg',
'url': 'chicken.html'
},
{
'name': 'chicken sandwich',
'image': 'sandwich.jpg',
'url': 'sandwich.html'
}
]
And my template is:
<div class="page-header">
<h1>Recipes Matching {{ query }}</h1>
{% for dict_item in names %}
<div>
<img src="{{ dict_item['image'] }}" height="100" width="100">
<a href="{{ dict_item['url'] }}">{{ dict_item['name'] }}</a>
</div>
{% endfor %}
</div>