Backport plugin_static template tag to 0.15.x (#7764)

This commit is contained in:
Lukas 2024-07-30 12:51:57 +02:00 committed by GitHub
parent 0d8eb2e0b3
commit 0f3b719c80
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2,6 +2,7 @@
from django import template
from django.conf import settings as djangosettings
from django.templatetags.static import static
from django.urls import reverse
from common.models import InvenTreeSetting
@ -96,3 +97,17 @@ def notification_list(context, *args, **kwargs):
}
for a in storage.liste
]
@register.simple_tag()
def plugin_static(file: str, **kwargs):
"""Return the URL for a static file within a plugin.
Arguments:
file: The path to the file within the plugin static directory
Keyword Arguments:
plugin: The plugin slug (optional, will be inferred from the context if not provided)
"""
return static(file)