1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Introduce badge template tag

This commit is contained in:
Jeremy Stretch
2020-07-02 14:29:23 -04:00
parent 92c889ef9e
commit a1e5a8b86a
2 changed files with 12 additions and 0 deletions
netbox
templates/utilities/templatetags
utilities/templatetags

@ -0,0 +1 @@
{% if value or show_empty %}<span class="badge">{{ value }}</span>{% endif %}

@ -242,3 +242,14 @@ def tag(tag, url_name=None):
'tag': tag,
'url_name': url_name,
}
@register.inclusion_tag('utilities/templatetags/badge.html')
def badge(value, show_empty=False):
"""
Display the specified number as a badge.
"""
return {
'value': value,
'show_empty': show_empty,
}