mirror of
https://github.com/kemko/liquid.git
synced 2026-01-01 15:55:40 +03:00
Merge pull request #761 from Shopify/range-to_liquid
Support Range Type
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user