mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-20 11:20:41 -07:00
Always stringify sum property.
This commit is contained in:
@@ -952,11 +952,13 @@ module Liquid
|
|||||||
# @liquid_syntax array | sum
|
# @liquid_syntax array | sum
|
||||||
# @liquid_return [number]
|
# @liquid_return [number]
|
||||||
def sum(input, property = nil)
|
def sum(input, property = nil)
|
||||||
|
property = Liquid::Utils.to_s(property)
|
||||||
|
|
||||||
ary = InputIterator.new(input, context)
|
ary = InputIterator.new(input, context)
|
||||||
return 0 if ary.empty?
|
return 0 if ary.empty?
|
||||||
|
|
||||||
values_for_sum = ary.map do |item|
|
values_for_sum = ary.map do |item|
|
||||||
if property.nil?
|
if property.empty?
|
||||||
item
|
item
|
||||||
elsif item.respond_to?(:[])
|
elsif item.respond_to?(:[])
|
||||||
item[property]
|
item[property]
|
||||||
|
|||||||
Reference in New Issue
Block a user