用液体计算聚合(例如 运行 总计)
Computing aggregate (e.g running total) with liquid
给定一个{ name: string; amount: float }
数组,如何写出总共运行个数据。
{% for entry in my_array %}
{{ entry.name }}, {{ entry.amount }}, {{ ???running total??? }}
{% endfor %}
这是您要找的吗?
{% assign running_total = 0 %}
{% for entry in my_array %}
{% assign running_total = running_total | plus: entry.amount %}
{% endfor %}
给定一个{ name: string; amount: float }
数组,如何写出总共运行个数据。
{% for entry in my_array %}
{{ entry.name }}, {{ entry.amount }}, {{ ???running total??? }}
{% endfor %}
这是您要找的吗?
{% assign running_total = 0 %}
{% for entry in my_array %}
{% assign running_total = running_total | plus: entry.amount %}
{% endfor %}