Am 28.01.2006 um 08:10 schrieb deezthugs:

I just want to print a <br/> after every 5th <a href>:

<span py:for="i,tag in enumerate(tag_list)" class="${i%2 and 'row_even' or 'row_odd'}">
  <a href="/go_tag?the_tag=${tag[2]}">${tag[1]}</a>${tag[0]}
  <!-- output <br> here after every 5th a href -->
 </span>

This seems so simple. I have spent an hour or more on this simple functionality with no sucess. This has got to be an easy task.

Easy:
<span py:for="i,tag in enumerate(tag_list)" class="${i%2 and 'row_even' or 'row_odd'}">
  <a href="/go_tag?the_tag=${tag[2]}">${tag[1]}</a>${tag[0]}
  <br py:if="(i % 5) == 0" />
 </span>

If the length of tag_list is divisible by 5, this will also ouitput a <br> at the end of the list. If you want to suppress this: <span py:for="i,tag in enumerate(tag_list)" class="${i%2 and 'row_even' or 'row_odd'}">
  <a href="/go_tag?the_tag=${tag[2]}">${tag[1]}</a>${tag[0]}
  <br py:if="(i % 5) == 0 and i != len(tag_list) - 1" />
 </span>

ciao
Martina

Reply via email to