Gracefully empty property in map filter

This commit is contained in:
Ian Ker-Seymer
2025-04-04 09:59:04 -04:00
parent 7900043ffc
commit 19e287dda2
2 changed files with 41 additions and 9 deletions
+4 -4
View File
@@ -536,11 +536,11 @@ module Liquid
# @liquid_syntax array | map: string
# @liquid_return [array[untyped]]
def map(input, property)
if property.nil?
raise_property_error(property)
end
property = Utils.to_s(property)
# Return the input array if property is empty (no-op)
return InputIterator.new(input, context).to_a if property.empty?
InputIterator.new(input, context).map do |e|
e = e.call if e.is_a?(Proc)