Remove the redundant iterable check in the for tag.

Just do it in slice_collection for consistency with the tablerow tag.
This commit is contained in:
Dylan Thacker-Smith
2015-05-28 16:04:23 -04:00
parent 873eddbb85
commit c1eb694057
2 changed files with 1 additions and 11 deletions

View File

@@ -76,9 +76,6 @@ module Liquid
collection = context.evaluate(@collection_name)
collection = collection.to_a if collection.is_a?(Range)
# Maintains Ruby 1.8.7 String#each behaviour on 1.9
return render_else(context) unless iterable?(collection)
from = if @from == :continue
for_offsets[@name].to_i
else
@@ -189,10 +186,6 @@ module Liquid
def render_else(context)
@else_block ? @else_block.render(context) : ''.freeze
end
def iterable?(collection)
collection.respond_to?(:each) || Utils.non_blank_string?(collection)
end
end
Template.register_tag('for'.freeze, For)

View File

@@ -8,10 +8,6 @@ module Liquid
end
end
def self.non_blank_string?(collection)
collection.is_a?(String) && collection != ''.freeze
end
def self.slice_collection_using_each(collection, from, to)
segments = []
index = 0
@@ -20,6 +16,7 @@ module Liquid
if collection.is_a?(String)
return collection.empty? ? [] : [collection]
end
return [] unless collection.respond_to?(:each)
collection.each do |item|
if to && to <= index