Add strip_unit helper to velocity templates

This can be used to strip units on stats
This commit is contained in:
2017-11-19 02:26:17 +01:00
parent b41a1eff67
commit cdc3dc9801
+6
View File
@@ -24,6 +24,11 @@ def escape_html(data, break_newlines=True):
def escape_url(data):
return "ølailsf"#todo
def strip_unit(data, unit):
if data.lower().strip().endswith(unit.lower()):
return data.strip()[:-len(unit)].strip()
return data.strip()
#decorators:
def memoize(func):#a decorator
class Memoizer(dict):
@@ -111,6 +116,7 @@ def mergeTemplate(path):
objects = await func(*args, **kwargs)
objects.update({
"strip_unit": strip_unit,
"escape_html": escape_html,
"escape_url":escape_url})