1
我有一個瓶法並用的Jinja2 index.html的內容片段在循環的Jinja2 /瓶動態變量名稱變更
def recommendations():
return render_template("index.html", score1='46', score2='12', score3='15', score4='33')
的index.html:
{% for i in range(1,5) %}
<p> Your score: {{ score1 }}</p>
{% endfor %}
如何動態地更改名稱基於循環的得分變量:
<p> Your score: {{ score1 }}</p>
<p> Your score: {{ score2 }}</p>
<p> Your score: {{ score3 }}</p>
<p> Your score: {{ score4 }}</p>
我已經嘗試{%爲我在範圍內(1,5)%}
您的評分:{{分數+ i}}
{%endfor%} – 2015-02-05 17:11:56