diff --git a/lib/liquid/standardfilters.rb b/lib/liquid/standardfilters.rb index 4fb771cd..caeb5d48 100644 --- a/lib/liquid/standardfilters.rb +++ b/lib/liquid/standardfilters.rb @@ -174,7 +174,8 @@ module Liquid if property == "to_liquid".freeze e elsif e.respond_to?(:[]) - e[property] + r = e[property] + r.is_a?(Proc) ? r.call : r end end end diff --git a/test/integration/standard_filter_test.rb b/test/integration/standard_filter_test.rb index a3d468a5..eb883844 100644 --- a/test/integration/standard_filter_test.rb +++ b/test/integration/standard_filter_test.rb @@ -249,6 +249,19 @@ class StandardFiltersTest < Minitest::Test assert_template_result "testfoo", templ, "procs" => [p] end + def test_map_over_drops_returning_procs + drops = [ + { + "proc" => ->{ "foo" }, + }, + { + "proc" => ->{ "bar" }, + }, + ] + templ = '{{ drops | map: "proc" }}' + assert_template_result "foobar", templ, "drops" => drops + end + def test_map_works_on_enumerables assert_template_result "123", '{{ foo | map: "foo" }}', "foo" => TestEnumerable.new end