我正在尝试做以下事情:
{% for position in positions %}
{% if position['symbol'] != 'CASH' %}
<tr>
<td>{{position['symbol']}}</td>
<td>{{position['name']}}</td>
<td>{{position['shares']}}</td>
<td>{{position['price']}}</td>
<td>{{position['total']}}</td>
</tr>
{% else %}
{% cash = position['total'] %}
<tr>
<td>{{cash}}</td>
</tr>
{% endif %}
{% endfor %}
有没有办法捕获'现金'并在以后的html中使用它?
答案 0 :(得分:3)
试试这个:{% set variable = cash %}