Question

<div tal:define="number python: 1">
<tal:block repeat="item s_items">
    <div tal:define="number python: number + 1">     
         <div tal:content="python: 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

Was it helpful?

Solution

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>

OTHER TIPS

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).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top