Skip to content

Commit

Permalink
Merge pull request #1 from cccaballero/master
Browse files Browse the repository at this point in the history
fix python3 standalone (non web2py) issues
  • Loading branch information
mdipierro committed Feb 18, 2019
2 parents 25c07c7 + e25a772 commit 8775e10
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions yatl/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -821,13 +821,20 @@ def write(self, data, escape=True):
if not escape:
self.body.write(str(data))
elif hasattr(data, 'xml') and callable(data.xml):
self.body.write(data.xml())
if PY2:
self.body.write(data.xml())
else:
self.body.write(str(data))
else:
# make it a string
if not isinstance(data, (str, unicodeT)):
data = str(data)
elif isinstance(data, unicodeT):
data = data.encode('utf8', 'xmlcharrefreplace')
if PY2:
if not isinstance(data, (str, unicodeT)):
data = str(data)
elif isinstance(data, unicodeT):
data = data.encode('utf8', 'xmlcharrefreplace')
else:
if not isinstance(data, str):
data = str(data)
data = html_escape(data, True).replace("'", "'")
self.body.write(data)

Expand Down

0 comments on commit 8775e10

Please sign in to comment.