From: Lukas Neumann Date: Sun, 10 Jun 2018 12:12:12 +0000 (+0200) Subject: fix(renderer): allow unicode for no-escape variables X-Git-Url: https://git.devinivas.org/?a=commitdiff_plain;h=87099af7c2a1ce0e768f4c30ce6f84a3f2897383;p=chevron.git fix(renderer): allow unicode for no-escape variables --- diff --git a/chevron/renderer.py b/chevron/renderer.py index 0a65bd0..4286f5b 100644 --- a/chevron/renderer.py +++ b/chevron/renderer.py @@ -203,7 +203,10 @@ def render(template='', data={}, partials_path='.', partials_ext='mustache', # If we're a no html escape tag elif tag == 'no escape': # Just lookup the key and add it - output += str(_get_key(key, scopes)) + thing = _get_key(key, scopes) + if type(thing) != unicode: + thing = unicode(str(thing), 'utf-8') + output += thing # If we're a section tag elif tag == 'section': diff --git a/tests/data.json b/tests/data.json index 4be7139..02f0451 100644 --- a/tests/data.json +++ b/tests/data.json @@ -12,5 +12,6 @@ "scope": { "test": "new test" }, - "unicode": "(╯°□°)╯︵ ┻━┻" + "unicode": "(╯°□°)╯︵ ┻━┻", + "unicode_html": "(╯°□°)╯︵ ┻━┻" } diff --git a/tests/test.mustache b/tests/test.mustache index 6a507e9..61cca18 100644 --- a/tests/test.mustache +++ b/tests/test.mustache @@ -140,3 +140,10 @@ unicode test (partial) === (╯°□°)╯︵ ┻━┻ === + +unicode test (no-escape) +=== +{{& unicode_html }} +=== +(╯°□°)╯︵ ┻━┻ +=== diff --git a/tests/test.rendered b/tests/test.rendered index 730bec2..9861850 100644 --- a/tests/test.rendered +++ b/tests/test.rendered @@ -124,3 +124,10 @@ unicode test (partial) === (╯°□°)╯︵ ┻━┻ === + +unicode test (no-escape) +=== +(╯°□°)╯︵ ┻━┻ +=== +(╯°□°)╯︵ ┻━┻ +===