开发者

zope and tal, repeat function

开发者 https://www.devze.com 2022-12-20 21:40 出处:网络
<div tal:define=\"number python: 1\"> <tal:block repeat=\"item s_items\"> <div tal:define=\"number python: number + 1\">
<div tal:define="number python: 1">
<tal:block repeat="item s_items">
    <div tal:define="number python: number + 1">     
         <div tal:content="pytho开发者_开发知识库n: number">none</div>
     </div> 
</tal:block>
</div>

Hi, always show 2. but I would like to show 2 3 4 5 ... How to do? Thanks


Sorry I'm a bit late ;-)

Wouldn't this be better solved with repeat variables?

<tal:loop repeat="item s_items">
    <div tal:content="repeat/item/number">1</div>
</tal:loop>

("loop" instead of "block" is just a matter of taste ...)

The name after "repeat" is the name of your iterator variable "item"; "number" starts with 1, "index" starts with 0 (there are more).


sorry for the delay, you could do something like.

<div tal:define="global number python: 1">
<tal:block repeat="item s_items">
<div tal:define="global number python: number + 1">     
     <div tal:content="python: number">none</div>
 </div> 
</tal:block>
</div>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号