python - Chameleon template engine: loop with index -


i practicing chameleon template engine bootstrap. layout using fluid layout.

in listing part of layout, using structure like

<div class="row-fluid">     <div class="span4">******</div>     <div class="span4">******</div>     <div class="span4">******</div> </div> <div class="row-fluid">     <div class="span4">******</div>     <div class="span4">******</div>     <div class="span4">******</div> </div> 

each row-fluid div contains 3 span4 div.

tal:repeat in chameleon repeats elements in list. if have 6 element in list, generates

<div class="row-fluid">     <div class="span4">******</div>     <div class="span4">******</div>     <div class="span4">******</div>     <div class="span4">******</div>     <div class="span4">******</div>     <div class="span4">******</div>     <div class="span4">******</div> </div> 

however, ruins previous layout.

is there anyway task chameleon?

the problem boils down splitting list evenly-sized chunks , using 2 nested loops iterate on "master" list , "sublists".

completely untested, think following starting point:

<div class="row-fluid" tal:repeat="chunk [l[i*3:(i*3)+3] in range((len(l) // 3) + 1) ]">     <div class="span4" tal:repeat="item chunk"><tal:item replace="item" /></div> </div> 

Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -