everyone, i met a problem in Flask. There is a table in mysql named category, I queried all of them, then passed them to a.html, like this :
return render_template('admin_index.html', username=session.get('username'), categories=categories)
In admin_index.html, I wanna list all of them, here is my code:
var _menus = {
"menus": [
{
"menuid": "1",
"icon": "icon-sys",
"menuname": "category",
"menus": [
{% for category in categories %}
{
"menuid": "{{ category.id }}",
"menuname":"{{ category.name }}",
"icon": "icon-users",
"url": "{{url_for('admin.category', id={{category.id}} _external=True) }}"
},
{% endfor %}
]
}
]
};
but when i ran this, i got an error:
jinja2.exceptions.TemplateSyntaxError: expected token ':', got '}'
I tried remove {{ category.id }}, turned out OK, I suspect it's not allowed to nest variables in Flask template, which like this :
{{ a is {{ b }} }}
Is there any way i can nest it?