I am new to JS and jinja2. I am wondering why I am getting this syntax error? The error is occurring in the for loop
Question:
var lineData = {
labels : [
{% for item in labels %}
"{{ item }}",
{% endfor %}
],
I am getting an error in the for loop. I am not sure where I am going wrong with the syntax.
Answers:
You can pass data to JavaScript within a template using the jinja filter tojson
.
var lineData = {
labels : {{ labels | tojson }},
// ...
}
var lineData = {
labels : [
{% for item in labels %}
"{{ item }}",
{% endfor %}
],
I am getting an error in the for loop. I am not sure where I am going wrong with the syntax.
You can pass data to JavaScript within a template using the jinja filter tojson
.
var lineData = {
labels : {{ labels | tojson }},
// ...
}