From 87099af7c2a1ce0e768f4c30ce6f84a3f2897383 Mon Sep 17 00:00:00 2001 From: Lukas Neumann Date: Sun, 10 Jun 2018 14:12:12 +0200 Subject: [PATCH] fix(renderer): allow unicode for no-escape variables --- chevron/renderer.py | 5 ++++- tests/data.json | 3 ++- tests/test.mustache | 7 +++++++ tests/test.rendered | 7 +++++++ 4 files changed, 20 insertions(+), 2 deletions(-) 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) +=== +(╯°□°)╯︵ ┻━┻ +=== +(╯°□°)╯︵ ┻━┻ +=== -- 2.47.3