mirror of
https://github.com/kemko/liquid.git
synced 2026-01-06 18:25:41 +03:00
Use array instead of Hash to keep the registered filters
1.8.7 compatibility fix In Ruby 1.8.7, Hash does not preserve insertion ordering as Array does. This could cause a problem when registering filters which depend on others and the registration order is important. So, the @@filters variable was changed to array where the order of the filters is the same as the insertion order.
This commit is contained in:
25
test/liquid/hash_ordering_test.rb
Normal file
25
test/liquid/hash_ordering_test.rb
Normal file
@@ -0,0 +1,25 @@
|
||||
require 'test_helper'
|
||||
|
||||
module MoneyFilter
|
||||
def money(input)
|
||||
sprintf(' %d$ ', input)
|
||||
end
|
||||
end
|
||||
|
||||
module CanadianMoneyFilter
|
||||
def money(input)
|
||||
sprintf(' %d$ CAD ', input)
|
||||
end
|
||||
end
|
||||
|
||||
class HashOrderingTest < Test::Unit::TestCase
|
||||
include Liquid
|
||||
|
||||
def test_global_register_order
|
||||
Template.register_filter(MoneyFilter)
|
||||
Template.register_filter(CanadianMoneyFilter)
|
||||
|
||||
assert_equal " 1000$ CAD ", Template.parse("{{1000 | money}}").render(nil, nil)
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user