Permalink
Browse files

Fix for-tag update to also work properly in Ruby 1.8.

* Follow up commit to 3d7c1c8
  • Loading branch information...
1 parent 3d7c1c8 commit b8d7b9aeda0a6592780c42ebfdfc9c0bbe9138ee @Soleone Soleone committed Feb 29, 2012
Showing with 6 additions and 2 deletions.
  1. +6 −2 lib/liquid/tags/for.rb
View
@@ -126,7 +126,7 @@ def slice_collection_using_each(collection, from, to)
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 @@ def render_else(context)
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

0 comments on commit b8d7b9a

Please sign in to comment.