Merge pull request #761 from Shopify/range-to_liquid

Support Range Type
This commit is contained in:
Gaurav Chande
2016-06-02 16:48:30 -04:00
2 changed files with 16 additions and 0 deletions

View File

@@ -25,6 +25,12 @@ class Numeric # :nodoc:
end
end
class Range # :nodoc:
def to_liquid
self
end
end
class Time # :nodoc:
def to_liquid
self

View File

@@ -306,4 +306,14 @@ class TemplateTest < Minitest::Test
t.render!({ 'x' => 'foo' }, { strict_filters: true })
end
end
def test_using_range_literal_works_as_expected
t = Template.parse("{% assign foo = (x..y) %}{{ foo }}")
result = t.render({ 'x' => 1, 'y' => 5 })
assert_equal '1..5', result
t = Template.parse("{% assign nums = (x..y) %}{% for num in nums %}{{ num }}{% endfor %}")
result = t.render({ 'x' => 1, 'y' => 5 })
assert_equal '12345', result
end
end