Jinja2 template syntax macro error - Stack Overflow
phpcn_u1582
phpcn_u1582 2017-06-12 09:25:17
0
1
923
{% macro msg_error(name) %}
    {% for error in form.{{ name }}.errors %}
      <H5>{{ error }}</H5>
    {% endfor %}
{% endmacro %}

I used macros in the jinja2 template syntax, but an error was reported. The problem is that the name is quoted incorrectly. How should the name be quoted correctly?

phpcn_u1582
phpcn_u1582

reply all(1)
迷茫

For example

@app.route('/error')
def func_error(func_name):
    return render_template('error.html',name=func_name)
    

name is the variable name in your template

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template