Skip to content
Myr

Pass context when using select

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Rens Groothuijsen · committed by David Lord · parent 7a41ddb · Browse files · 3 files+15 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+15 added−1 removed

  • tests:+12 added−0 removed
  • other:+3 added−1 removed

3 files+15 added−1 removed

modified:src/jinja2/filters.py+1 added-1 removed
1778 unmodified lines
1779 name = args[off]1780 args = args[1 + off :]17811782 def func(item: t.Any) -> t.Any:1783 return context.environment.call_test(name, item, args, kwargs)1783 return context.environment.call_test(name, item, args, kwargs, context)17841785 except LookupError:1786 func = bool # type: ignore1787
91 unmodified lines
modified:tests/test_regression.py+12 added
735 unmodified lines
736 "{% endset %}{{ output }}"737 )738 assert tmpl.render() == "hellohellohello"739740 def test_pass_context_with_select(self, env):741 @pass_context742 def is_foo(ctx, s):743 assert ctx is not None744 return s == "foo"745746 env.tests["foo"] = is_foo747 tmpl = env.from_string(748 "{% for x in ['one', 'foo'] | select('foo') %}{{ x }}{% endfor %}"749 )750 assert tmpl.render() == "foo"751752753@pytest.mark.parametrize("unicode_char", ["\N{FORM FEED}", "\x85"])754def test_unicode_whitespace(env, unicode_char):755 content = "Lorem ipsum\n" + unicode_char + "\nMore text"756 tmpl = env.from_string(content)
1 unmodified line
modified:CHANGES.rst+2 added
39 unmodified lines
40- ``PackageLoader`` shows a clearer error message when the package does not41 contain the templates directory. :issue:`1705`42- Improve annotations for methods returning copies. :pr:`1880`43- ``urlize`` does not add ``mailto:`` to values like `@a@b`. :pr:`1870`44- Tests decorated with `@pass_context`` can be used with the ``|select``45 filter. :issue:`1624`464748Version 3.1.449-------------
994 unmodified lines