Django Template 设定某值

{% with name="World" greeting="Hello" %} 
<html>
<div>{{ greeting }} {{name}}!</div>
</html>
{% endwith %}

注意如果template有其他控制语句,有可能出现嵌套错误,例如:

{% with name="D" %} 
{% for item in inputList %}
<p>
<button type="submit" value="{{name}}-{{forloop.counter0}}" name="bt">编辑</button>
</p>

{% endwith %}
{% endfor %}

会报错,必须调整交换endwith和endfor的位置。

posted on 2013-04-06 23:09  0x9801  阅读(109)  评论(0)    收藏  举报

导航