Closed NL-TCH closed 2 years ago
You appear to have a misunderstanding here. Context Processor functions are a feature of Flask that have nothing to do wtih Turbo-Flask. https://flask.palletsprojects.com/en/2.0.x/templating/#context-processors. A context processor must return a dictionary.
You may be able to use something like return {'mylist': list}
, or you can also not use context processors and just send what you want to render in the template directly as arguments into the render_template
function call.
thanks for the fast reply! yeah that works by setting the list in a 1variable dict like:
@app.context_processor
def inject_load():
tweets=functions.tweets_ophalen()
return {'var1': tweets[:]}
and my html like:
<div id="load" class="load">
<section class="services">
<div class="container-fluid">
<div class="row">
{% for naam,titel,klacht in var1 %}
<div class="col-md-4">
<div class="service-item first-item" style="cursor: pointer; height: 450px">
<div class="icon"></div>
<h2>{{ titel }}</h2>
<br />
<h3><b>{{ naam }}:</b> {{ klacht }}</h3>
</p>
</div>
</div>
{% endfor %}
</div>
</div>
</section>
</div>
i want to inject a list instead of a dictionary, your template is:
i have it like this:
the function tweets_ophalen() returns a list, but the turbo_flask module does not like it. i get the following error:
i really like the concept of turbo-flask but i am not in a position to change the (big) list into a dict. and would like to see an option to parse lists instead of dicts.
thanks in advance!