Home
Sign Up
Sign In
Tornado Documentation
›
http://www.v2ex.com/tornado/
Tornado on GitHub
›
https://github.com/facebook/tornado/
Tornado Gists
›
http://tornadogists.org/
V2EX
›
Tornado
请教一个Tornado框架模板中循环的问题。
paulguo
·
Jul 11, 2012
· 6729 views
This topic created in 5227 days ago, the information mentioned may be changed or developed.
{% for i in data %}
...
<div class="">
</div>
{% end %}
如何每隔一条输出一个className标志?
div
END
Data
7 replies
•
1970-01-01 08:00:00 +08:00
Brutal
Jul 11, 2012
1
{% set i = 1%}
<div class="{% if i % 2 == 0 %} className {% end %}">
...
{% set i = i + 1 %}
paulguo
OP
Jul 11, 2012
2
@
Brutal
thanks.
yoyicue
Jul 11, 2012
3
https://groups.google.com/group/python-tornado/browse_thread/thread/14821f99691291f8
木有 jinja2 优雅
paulguo
OP
Jul 11, 2012
4
@
yoyicue
确实,tornado自带的的确有点弱,未定义的变量都没法检测,还要try。
CoX
Jul 12, 2012
1
5
{% for idx,item in enumerate(data) %}
...
<div class="{% if idx % 2 == 0 %} className {% end %}">
</div>
{% end %}
paulguo
OP
Jul 12, 2012
6
@
Cox
thanks~ 这样好很多
hartnett
Jan 7, 2013
7
thx,不错的方法。
About
·
Help
·
Advertise
·
Blog
·
API
·
FAQ
·
Privacy
·
Solana
·
4815 Online
Highest 6679
·
Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 29ms ·
UTC 00:10
·
PVG 08:10
·
LAX 16:10
·
JFK 19:10
♥ Do have faith in what you're doing.
❯