We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@pass_context
select
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:
The text was updated successfully, but these errors were encountered:
No branches or pull requests
When used from
select
, tests that are decorated with@pass_context
fail with the error:For example:
Environment:
The text was updated successfully, but these errors were encountered: