[stable-2.19] Fix filter plugin result processing (#85653) (#85662)

(cherry picked from commit 76748b8478)
This commit is contained in:
Matt Clay
2025-08-15 12:22:27 -07:00
committed by GitHub
parent db4973572a
commit 0718473815
3 changed files with 25 additions and 2 deletions
@@ -1078,3 +1078,18 @@ def test_marker_from_test_plugin() -> None:
"""Verify test plugins can raise MarkerError to return a Marker, and that no warnings or deprecations are emitted."""
with emits_warnings(deprecation_pattern=[], warning_pattern=[]):
assert TemplateEngine(variables=dict(something=TRUST.tag("{{ nope }}"))).template(TRUST.tag("{{ (something is eq {}) is undefined }}"))
def test_filter_generator() -> None:
"""Verify that filters which return a generator are converted to a list while under the filter's JinjaCallContext."""
variables = dict(
foo=[
dict(x=1, optional_var=0),
dict(x=2),
],
bar=TRUST.tag("{{ foo | selectattr('optional_var', 'defined') }}"),
)
te = TemplateEngine(variables=variables)
te.template(TRUST.tag("{{ bar }}"))
te.template(TRUST.tag("{{ lookup('vars', 'bar') }}"))