From b0d634a89ec39dadbdb90d42b42d18c22e89aca9 Mon Sep 17 00:00:00 2001 From: checktheroads Date: Mon, 15 Mar 2021 08:53:28 -0700 Subject: [PATCH] add startswith helper --- netbox/utilities/templatetags/helpers.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/netbox/utilities/templatetags/helpers.py b/netbox/utilities/templatetags/helpers.py index 01dce8479..dc01c7bcc 100644 --- a/netbox/utilities/templatetags/helpers.py +++ b/netbox/utilities/templatetags/helpers.py @@ -228,6 +228,16 @@ def meters_to_feet(n): return float(n) * 3.28084 +@register.filter("startswith") +def startswith(text: str, starts: str) -> bool: + """ + Template implementation of `str.startswith()`. + """ + if isinstance(text, str): + return text.startswith(starts) + return False + + # # Tags #