Shopify / liquid

Liquid markup language. Safe, customer facing template language for flexible web apps.
https://shopify.github.io/liquid/
MIT License
11.13k stars 1.39k forks source link

Add `sum` filter to standard filters #1722

Closed adamklingbaum closed 1 year ago

adamklingbaum commented 1 year ago

A new filter to sum the values of an array. Either an ordinary sum for an array of numeric values, or as the sum of property values for an array of objects.

{{ array | sum }}

or

{{ array | sum: {property} }}

Example usage

{{ card_balances | sum }} 

or

{{ articles | sum: 'comments_count' }}