I\'m using Python 2.6 and Jinja2 to create HTML reports. I provide the template with many results and the template loops through them and creates HTML tables
When callin
Just encountered the same problem in a piece of code which saves output from Jinja2 to HTML files:
with open(path, 'wb') as fh:
fh.write(template.render(...))
It's easy to blame Jinja2, although the actual problem is in Python's open()
which as of version 2.7 doesn't support UTF-8. The fix is as simple as:
import codecs
with codecs.open(path, 'wb', 'utf-8') as fh:
fh.write(template.render(...))