]> Devi Nivas Git - chevron.git/commitdiff
fix(renderer): allow unicode for no-escape variables
authorLukas Neumann <lksnmnn@gmail.com>
Sun, 10 Jun 2018 12:12:12 +0000 (14:12 +0200)
committerLukas Neumann <lksnmnn@gmail.com>
Sun, 10 Jun 2018 12:12:12 +0000 (14:12 +0200)
chevron/renderer.py
tests/data.json
tests/test.mustache
tests/test.rendered

index 0a65bd0469b92731c0019a92bfae67fcac437a48..4286f5bd5c1768430882d870f5f31942ead35d1c 100644 (file)
@@ -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':
index 4be713946942ac01cdf725c0363e36e23580619b..02f0451d4430761942ec0257c07ae239e73662c5 100644 (file)
@@ -12,5 +12,6 @@
   "scope": {
       "test": "new test"
   },
-  "unicode": "(╯°□°)╯︵ ┻━┻"
+  "unicode": "(╯°□°)╯︵ ┻━┻",
+  "unicode_html": "<a>(╯°□°)╯︵ ┻━┻"
 }
index 6a507e96de3450aae444a6f72dc33e1b9c777a33..61cca181914a60d683602f132560da1ecd4f8191 100644 (file)
@@ -140,3 +140,10 @@ unicode test (partial)
 ===
 (╯°□°)╯︵ ┻━┻
 ===
+
+unicode test (no-escape)
+===
+{{& unicode_html }}
+===
+<a>(╯°□°)╯︵ ┻━┻
+===
index 730bec2e653a2c77682634df7262c695334ec103..9861850c29e66a114bd451da4f489683ce566d14 100644 (file)
@@ -124,3 +124,10 @@ unicode test (partial)
 ===
 (╯°□°)╯︵ ┻━┻
 ===
+
+unicode test (no-escape)
+===
+<a>(╯°□°)╯︵ ┻━┻
+===
+<a>(╯°□°)╯︵ ┻━┻
+===