Added backwards compatibility for 1.8.7 String.each returning itself (and 1.9.3 not supporting .each).

Moved for tag tests to their own test model from StandardTagTest.
This commit is contained in:
Kristian PD
2012-01-20 16:45:41 -05:00
parent 1a1b4702d7
commit 01dea94671
3 changed files with 205 additions and 167 deletions
+6 -1
View File
@@ -75,7 +75,8 @@ module Liquid
collection = context[@collection_name]
collection = collection.to_a if collection.is_a?(Range)
return render_else(context) unless collection.respond_to?(:each)
# 1.8.7 compatibility
return render_else(context) unless collection.respond_to?(:each) or collection.is_a?(String)
from = if @attributes['offset'] == 'continue'
context.registers[:for][@name].to_i
@@ -123,6 +124,10 @@ module Liquid
segments = []
index = 0
yielded = 0
# 1.8.7 compatibility
return [collection] if collection.is_a?(String)
collection.each do |item|
if to && to <= index