mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-14 09:51:22 -06:00
Add configuration option JINJA2_FILTERS
This commit is contained in:
parent
c81c3d11ed
commit
d1aa820856
@ -255,6 +255,20 @@ HTTP_PROXIES = {
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## JINJA2_FILTERS
|
||||||
|
|
||||||
|
Default: `{}`
|
||||||
|
|
||||||
|
A dictionary of custom jinja2 filters with the key being the filter name and the value being a callable. For more information see the [jinja2 documentation](https://jinja.palletsprojects.com/en/3.1.x/api/#custom-filters). For example:
|
||||||
|
|
||||||
|
```python
|
||||||
|
JINJA2_FILTERS = {
|
||||||
|
'uppercase': uppercase,
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## INTERNAL_IPS
|
## INTERNAL_IPS
|
||||||
|
|
||||||
Default: `('127.0.0.1', '::1')`
|
Default: `('127.0.0.1', '::1')`
|
||||||
|
@ -96,6 +96,7 @@ EXEMPT_VIEW_PERMISSIONS = getattr(configuration, 'EXEMPT_VIEW_PERMISSIONS', [])
|
|||||||
FIELD_CHOICES = getattr(configuration, 'FIELD_CHOICES', {})
|
FIELD_CHOICES = getattr(configuration, 'FIELD_CHOICES', {})
|
||||||
HTTP_PROXIES = getattr(configuration, 'HTTP_PROXIES', None)
|
HTTP_PROXIES = getattr(configuration, 'HTTP_PROXIES', None)
|
||||||
INTERNAL_IPS = getattr(configuration, 'INTERNAL_IPS', ('127.0.0.1', '::1'))
|
INTERNAL_IPS = getattr(configuration, 'INTERNAL_IPS', ('127.0.0.1', '::1'))
|
||||||
|
JINJA2_FILTERS = getattr(configuration, 'JINJA2_FILTERS', {})
|
||||||
LOGGING = getattr(configuration, 'LOGGING', {})
|
LOGGING = getattr(configuration, 'LOGGING', {})
|
||||||
LOGIN_PERSISTENCE = getattr(configuration, 'LOGIN_PERSISTENCE', False)
|
LOGIN_PERSISTENCE = getattr(configuration, 'LOGIN_PERSISTENCE', False)
|
||||||
LOGIN_REQUIRED = getattr(configuration, 'LOGIN_REQUIRED', False)
|
LOGIN_REQUIRED = getattr(configuration, 'LOGIN_REQUIRED', False)
|
||||||
|
@ -14,6 +14,7 @@ from mptt.models import MPTTModel
|
|||||||
from dcim.choices import CableLengthUnitChoices
|
from dcim.choices import CableLengthUnitChoices
|
||||||
from extras.plugins import PluginConfig
|
from extras.plugins import PluginConfig
|
||||||
from extras.utils import is_taggable
|
from extras.utils import is_taggable
|
||||||
|
from netbox.config import get_config
|
||||||
from utilities.constants import HTTP_REQUEST_META_SAFE_COPY
|
from utilities.constants import HTTP_REQUEST_META_SAFE_COPY
|
||||||
|
|
||||||
|
|
||||||
@ -257,7 +258,9 @@ def render_jinja2(template_code, context):
|
|||||||
"""
|
"""
|
||||||
Render a Jinja2 template with the provided context. Return the rendered content.
|
Render a Jinja2 template with the provided context. Return the rendered content.
|
||||||
"""
|
"""
|
||||||
return SandboxedEnvironment().from_string(source=template_code).render(**context)
|
environment = SandboxedEnvironment()
|
||||||
|
environment.filters.update(get_config().JINJA2_FILTERS)
|
||||||
|
return environment.from_string(source=template_code).render(**context)
|
||||||
|
|
||||||
|
|
||||||
def prepare_cloned_fields(instance):
|
def prepare_cloned_fields(instance):
|
||||||
|
Loading…
Reference in New Issue
Block a user