mirror of
https://github.com/kemko/liquid.git
synced 2026-01-06 18:25:41 +03:00
add flatten filter
This commit is contained in:
@@ -149,6 +149,16 @@ class StandardFiltersTest < Test::Unit::TestCase
|
||||
"thing" => { "foo" => [ { "bar" => 42 }, { "bar" => 17 } ] }
|
||||
end
|
||||
|
||||
def test_flatten
|
||||
assert_equal [1,2,3,4], @filters.flatten([1,2,3,4])
|
||||
assert_equal [1,2,3,4], @filters.flatten([[1,2,3,4]])
|
||||
assert_equal [1,2,3,4], @filters.flatten([[1],[2],[3],[4]])
|
||||
assert_equal [1], @filters.flatten(1)
|
||||
|
||||
assert_template_result '1234', "{{ ary | flatten | flatten }}",
|
||||
'ary' => [[1],2,[3],4]
|
||||
end
|
||||
|
||||
def test_sort_calls_to_liquid
|
||||
t = TestThing.new
|
||||
Liquid::Template.parse('{{ foo | sort: "whatever" }}').render("foo" => [t])
|
||||
|
||||
Reference in New Issue
Block a user