Handle unkown variables when rendering template

This commit is contained in:
shortcutme 2019-11-19 01:38:22 +01:00
parent 5c27a0efcc
commit 08574bf676
No known key found for this signature in database
GPG Key ID: 5B63BAE6CB9613AE
1 changed files with 4 additions and 1 deletions

View File

@ -318,7 +318,10 @@ class UiRequest(object):
template = open(template_path, encoding="utf8").read()
def renderReplacer(m):
return "%s" % kwargs.get(m.group(1), "")
if m.group(1) in kwargs:
return "%s" % kwargs.get(m.group(1), "")
else:
return m.group(0)
template_rendered = re.sub("{(.*?)}", renderReplacer, template)