From 39fecd06db1424ea8b7e222141b3f5686feb6270 Mon Sep 17 00:00:00 2001 From: Justin Li Date: Tue, 12 Mar 2019 12:18:22 -0400 Subject: [PATCH] Fix interrupts through includes --- lib/liquid/block_body.rb | 1 + test/integration/tags/include_tag_test.rb | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/lib/liquid/block_body.rb b/lib/liquid/block_body.rb index 266d8ed..ba29415 100644 --- a/lib/liquid/block_body.rb +++ b/lib/liquid/block_body.rb @@ -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 diff --git a/test/integration/tags/include_tag_test.rb b/test/integration/tags/include_tag_test.rb index 1d854b0..9c188d5 100644 --- a/test/integration/tags/include_tag_test.rb +++ b/test/integration/tags/include_tag_test.rb @@ -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