mirror of
https://github.com/Shopify/liquid.git
synced 2026-10-03 17:15:12 -07:00
Fix exception from using an empty string for the table row collection.
This commit is contained in:
+1
-1
@@ -17,7 +17,7 @@ module Liquid
|
|||||||
index = 0
|
index = 0
|
||||||
|
|
||||||
# Maintains Ruby 1.8.7 String#each behaviour on 1.9
|
# Maintains Ruby 1.8.7 String#each behaviour on 1.9
|
||||||
return [collection] if non_blank_string?(collection)
|
return collection != ''.freeze ? [collection] : [] if collection.is_a?(String)
|
||||||
|
|
||||||
collection.each do |item|
|
collection.each do |item|
|
||||||
if to && to <= index
|
if to && to <= index
|
||||||
|
|||||||
@@ -57,4 +57,8 @@ class TableRowTest < Minitest::Test
|
|||||||
'{% tablerow n in numbers cols:3 offset:1 limit:6%} {{n}} {% endtablerow %}',
|
'{% tablerow n in numbers cols:3 offset:1 limit:6%} {{n}} {% endtablerow %}',
|
||||||
'numbers' => [0, 1, 2, 3, 4, 5, 6, 7])
|
'numbers' => [0, 1, 2, 3, 4, 5, 6, 7])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_blank_string_not_iterable
|
||||||
|
assert_template_result("<tr class=\"row1\">\n</tr>\n", "{% tablerow char in characters cols:3 %}I WILL NOT BE OUTPUT{% endtablerow %}", 'characters' => '')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user