Awee

sum

Sum returns the numeric sum of the elements of a slice.

Sum returns the numeric sum of the elements of a slice. With no parameter, every element must be (or be parseable as) a number. With a string field parameter, each element is treated as a map and the named field is summed.

Input

array

Parameters

#TypeRequired
0stringno

Returns

float

Examples

Total a list of amounts

Input

amounts = [12.50, 8.00, 4.25]

Template

{{ amounts | sum }}

Output

24.75

Total an order from line items

Input

items = [{"name": "Mug", "price": 12}, {"name": "Pen", "price": 3}, {"name": "Pad", "price": 5}]

Template

{{ items | sum:'price' }}

Output

20

How is this guide?

On this page