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.
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 ) %}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With