Reputation: 6764
How to set format a string with unicode value in Jinja2 template?
{% set left='<span class="link" onclick="toggleLoginRegister(this)">{0}</span>'.format( registerHint ) %}
Raises UnicodeEncodeError if registerHint is a unicode string. Otherwise doesn't.
Upvotes: 5
Views: 6424
Reputation: 1124748
Use the |format()
filter instead and Jinja will decode your string literal to unicode
for you:
{% set left='<span class="link" onclick="toggleLoginRegister(this)">%s</span>'|format( registerHint ) %}
Upvotes: 10