Made my own html escape function to replace the cgi import.
Also updated the test.mustache and data.json files to have an
escaped string get printed.
"thing": "world",
"html_escaped": "<b>no escape!</b>",
"html_escaped2": "<i>ok</i>",
+ "html_escaped3": "<i> this is escaped though </i>",
"show": true,
"delimiter": {
"1": "do delimiters work?",
from sys import argv
from io import StringIO
-from cgi import escape as html_escape
def tokenize(template):
Returns:
A string containing the rendered template.
"""
+
+ def html_escape(string):
+ html_codes = {
+ '"': '$quot;',
+ '&': '&',
+ '<': '<',
+ '>': '>',
+ }
+
+ def escape_char(char):
+ return html_codes.get(char, char)
+
+ try:
+ return ''.join(map(escape_char, string))
+ except TypeError:
+ return ''
+
def get_key(key):
for scope in scopes:
try:
{{{html_escaped}}}
{{&html_escaped2}}
+{{html_escaped3}}
{{#show}}
Show is true!