mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-16 09:20:42 -07:00
Special case Hash#last in variable lookup
Ruby's defines Hash#first via Enumerable but not Hash#last. This is a confusing behaviour, and it bubbles up to Liquid. Solution: add a special case for command-lookups of Hash#last to return hash.values.last.
This commit is contained in:
@@ -130,4 +130,8 @@ class VariableTest < Minitest::Test
|
||||
def test_raw_value_variable
|
||||
assert_template_result('bar', '{{ [key] }}', { 'key' => 'foo', 'foo' => 'bar' })
|
||||
end
|
||||
|
||||
def test_hash_last
|
||||
assert_template_result('last', '{{ hash.last }}', { 'hash' => { 'first' => 'first', 'last' => 'last' } })
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user