-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Milestone
Description
When used from select
, tests that are decorated with @pass_context
fail with the error:
jinja2.exceptions.TemplateRuntimeError: Attempted to invoke a context test without context.
For example:
from jinja2 import Environment, pass_context
def main():
env = Environment()
env.tests["foo"] = is_foo
output = env.from_string("""
works: {{ "foo" is foo }}
{%- for x in ["one", "foo" ] | select("foo") %}
fails: {{ x }}
{%- endfor %}
""").render({})
print(output)
@pass_context
def is_foo(ctx, s):
return s == "foo"
if __name__ == "__main__":
main()
Environment:
- Python version: 3.10
- Jinja version: 3.0.3
Metadata
Metadata
Assignees
Labels
No labels