Support non-string values

This commit is contained in:
Keith Ainsworth 2014-05-06 14:18:02 -07:00
parent f2592f257d
commit e31b3e9655

View File

@ -252,13 +252,16 @@ def render_jinja_tmpl(tmplstr, context, tmplpath=None):
unicode_context = {}
for key, value in context.iteritems():
if isinstance(value, unicode):
if not isinstance(value, string_types):
unicode_context[key] = value
continue
# Let's try UTF-8 and fail if this still fails, that's why this is not
# wrapped in a try/except
unicode_context[key] = unicode(value, 'utf-8')
if isinstance(value, unicode):
unicode_context[key] = value
else:
unicode_context[key] = unicode(value, 'utf-8')
try:
template = jinja_env.from_string(tmplstr)