From e790b60f602a0ca70a95625750a209f62b27557b Mon Sep 17 00:00:00 2001 From: Dylan Thacker-Smith Date: Thu, 28 May 2015 11:56:52 -0400 Subject: [PATCH] Fix exception from using an empty string for the table row collection. --- lib/liquid/utils.rb | 2 +- test/integration/tags/table_row_test.rb | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/liquid/utils.rb b/lib/liquid/utils.rb index ed1e9d91..c1c71eb4 100644 --- a/lib/liquid/utils.rb +++ b/lib/liquid/utils.rb @@ -17,7 +17,7 @@ module Liquid index = 0 # 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| if to && to <= index diff --git a/test/integration/tags/table_row_test.rb b/test/integration/tags/table_row_test.rb index 6405a9c4..d7bc14cf 100644 --- a/test/integration/tags/table_row_test.rb +++ b/test/integration/tags/table_row_test.rb @@ -57,4 +57,8 @@ class TableRowTest < Minitest::Test '{% tablerow n in numbers cols:3 offset:1 limit:6%} {{n}} {% endtablerow %}', 'numbers' => [0, 1, 2, 3, 4, 5, 6, 7]) end + + def test_blank_string_not_iterable + assert_template_result("\n\n", "{% tablerow char in characters cols:3 %}I WILL NOT BE OUTPUT{% endtablerow %}", 'characters' => '') + end end