Add strip_unit helper to velocity templates
This can be used to strip units on stats
This commit is contained in:
@@ -24,6 +24,11 @@ def escape_html(data, break_newlines=True):
|
|||||||
def escape_url(data):
|
def escape_url(data):
|
||||||
return "ølailsf"#todo
|
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:
|
#decorators:
|
||||||
def memoize(func):#a decorator
|
def memoize(func):#a decorator
|
||||||
class Memoizer(dict):
|
class Memoizer(dict):
|
||||||
@@ -111,6 +116,7 @@ def mergeTemplate(path):
|
|||||||
objects = await func(*args, **kwargs)
|
objects = await func(*args, **kwargs)
|
||||||
|
|
||||||
objects.update({
|
objects.update({
|
||||||
|
"strip_unit": strip_unit,
|
||||||
"escape_html": escape_html,
|
"escape_html": escape_html,
|
||||||
"escape_url":escape_url})
|
"escape_url":escape_url})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user