Fix interrupts through includes

This commit is contained in:
Justin Li
2019-03-12 12:18:22 -04:00
parent 8013df8ca2
commit 39fecd06db
2 changed files with 9 additions and 0 deletions

View File

@@ -89,6 +89,7 @@ module Liquid
break
else # Other non-Block tags
render_node_to_output(node, output, context)
break if context.interrupt? # might have happened through an include
end
idx += 1
end

View File

@@ -30,6 +30,9 @@ class TestFileSystem
when 'assignments'
"{% assign foo = 'bar' %}"
when 'break'
"{% break %}"
else
template_path
end
@@ -242,4 +245,9 @@ class IncludeTagTest < Minitest::Test
assert_equal [], template.errors
end
def test_break_through_include
assert_template_result "1", "{% for i in (1..3) %}{{ i }}{% break %}{{ i }}{% endfor %}"
assert_template_result "1", "{% for i in (1..3) %}{{ i }}{% include 'break' %}{{ i }}{% endfor %}"
end
end # IncludeTagTest