From b8d7b9aeda0a6592780c42ebfdfc9c0bbe9138ee Mon Sep 17 00:00:00 2001 From: Dennis Theisen Date: Wed, 29 Feb 2012 16:13:46 -0500 Subject: [PATCH] Fix for-tag update to also work properly in Ruby 1.8. * Follow up commit to 3d7c1c8 --- lib/liquid/tags/for.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/liquid/tags/for.rb b/lib/liquid/tags/for.rb index fd6c3d9..a2ece81 100644 --- a/lib/liquid/tags/for.rb +++ b/lib/liquid/tags/for.rb @@ -126,7 +126,7 @@ module Liquid yielded = 0 # Maintains Ruby 1.8.7 String#each behaviour on 1.9 - return [collection] if collection.is_a?(String) + return [collection] if non_blank_string?(collection) collection.each do |item| @@ -151,7 +151,11 @@ module Liquid end def iterable?(collection) - collection.respond_to?(:each) || (collection.is_a?(String) && collection != '') + collection.respond_to?(:each) || non_blank_string?(collection) + end + + def non_blank_string?(collection) + collection.is_a?(String) && collection != '' end end