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