给定一个{ name: string; amount: float }
数组,如何写出运行总数的数据。
{% for entry in my_array %}
{{ entry.name }}, {{ entry.amount }}, {{ ???running total??? }}
{% endfor %}
答案 0 :(得分:1)
这是你要找的吗?
{% assign running_total = 0 %}
{% for entry in my_array %}
{% assign running_total = running_total | plus: entry.amount %}
{% endfor %}