Skip to content

Commit 6372289

Browse files
authored
Ensure we use InputIterator#each when in join filter (#1898)
1 parent 0ec52a4 commit 6372289

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

lib/liquid/standardfilters.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1065,7 +1065,7 @@ def initialize(input, context)
10651065
def join(glue)
10661066
first = true
10671067
output = +""
1068-
@input.each do |item|
1068+
each do |item|
10691069
if first
10701070
first = false
10711071
else

test/integration/standard_filter_test.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,16 @@ def test_join
305305
assert_equal('1121314', @filters.join([1, 2, 3, 4], 1))
306306
end
307307

308+
def test_join_calls_to_liquid_on_each_element
309+
drop = Class.new(Liquid::Drop) do
310+
def to_liquid
311+
'i did it'
312+
end
313+
end
314+
315+
assert_equal('i did it, i did it', @filters.join([drop.new, drop.new], ", "))
316+
end
317+
308318
def test_sort
309319
assert_equal([1, 2, 3, 4], @filters.sort([4, 3, 2, 1]))
310320
assert_equal([{ "a" => 1 }, { "a" => 2 }, { "a" => 3 }, { "a" => 4 }], @filters.sort([{ "a" => 4 }, { "a" => 3 }, { "a" => 1 }, { "a" => 2 }], "a"))

0 commit comments

Comments
 (0)