Skip to content

Commit

Permalink
feat: add a test case to ensure local vars are forwarded in context
Browse files Browse the repository at this point in the history
  • Loading branch information
CNSeniorious000 committed Oct 9, 2024
1 parent 7945278 commit a251596
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion python/tests/test_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,10 @@ def test_components_context():
assert Template("{% a b=1, c=2 %}").render({"a": Template("{{ b }}{{ c }}{{ d }}"), "d": 3}) == "123"


def test_components_in_for_loop():
assert Template("{% for i in '123' %}{% a %}{% endfor %}").render({"a": Template("{{ i }}")}) == "123"


def test_else_tag_in_for_loop():
render_assert("{% for i in '123' %}{{ i }}{% else %}4{% endfor %}", None, "1234")

Expand All @@ -386,7 +390,11 @@ def test_elif_tag():


def test_while_loop():
render_assert("{% while nums %}{{ nums.pop() }}{% else %}!{% endwhile %}", {"nums": [1, 2, 3]}, "321!")
render_assert(
"{% while nums %}{{ nums.pop() }}{% else %}!{% endwhile %}",
{"nums": [1, 2, 3]},
"321!",
)


def test_custom_indent():
Expand Down

0 comments on commit a251596

Please sign in to comment.