Is there a way to handle exceptions within a template in jinja2?
{% for item in items %}
{{ item|urlencode }} <-- item contains a unicode string that contains a character causes urlencode to throw KeyError
{% endfor %}
How do I handle that exception so that I can just skip that item or handle it without forcing the entire template rendering to fail?
Thanks!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…