Custom Jinja tests ? #15365
Unanswered
ajsiersema
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I couldn't find if enabling custom Jinja2 tests has been discussed before, it would be a simple change in
netbox/utilities/utils.py
:def render_jinja2(template_code, context): """ Render a Jinja2 template with the provided context. Return the rendered content. """ environment = SandboxedEnvironment() environment.filters.update(get_config().JINJA2_FILTERS) + environment.tests.update(get_config().JINJA2_TESTS) return environment.from_string(source=template_code).render(**context)
I could submit a PR ?
My use case for this would be to include the
search
,match
andregex
tests.Beta Was this translation helpful? Give feedback.
All reactions