Add new template_tag for defining variables

This commit is contained in:
Oliver Walters 2020-10-26 09:11:25 +11:00
parent ffe15763a7
commit 815d4bf7eb

View File

@ -12,6 +12,19 @@ from common.models import InvenTreeSetting, ColorTheme
register = template.Library()
@register.simple_tag()
def define(value, *args, **kwargs):
"""
Shortcut function to overcome the shortcomings of the django templating language
Use as follows: {% define "hello_world" as hello %}
Ref: https://stackoverflow.com/questions/1070398/how-to-set-a-value-of-a-variable-inside-a-template-code
"""
return value
@register.simple_tag()
def decimal(x, *args, **kwargs):
""" Simplified rendering of a decimal number """