Template FOR loop

Mark Ingram mark.ingram at nexsan.com
Wed Aug 6 10:36:03 UTC 2003


Thanks,

unless ive missed it there appears to be no way of doing a standard FOR
loop, so i just used a WHILE loop.

Heres what i ended up with anyways:

  [% count = 0 %]

  <option value="0"[% IF limit == 0 %] selected[% END %]>ALL</option>

  [% max_count = num_bugs div 5 %]
  [% IF num_bugs mod 5 == 0 %]
  	[% max_count = max_count - 1 %]
  [% END %]

  [% WHILE count < max_count %]
  	[% value = ((count + 1) * 5) %]
	<option value="[% value %]"[% IF value == limit %] selected[% END %]>[%
value %]</option>
  	[% count = count + 1 %]
  [% END %]

Cheers.

Best Regards,

Mark Ingram
Software Engineer
Nexsan Technologies
33 - 35 Parker Centre
Mansfield Road
Derby
DE21 4SZ



-----Original Message-----
From: developers-owner at bugzilla.org
[mailto:developers-owner at bugzilla.org]On Behalf Of J. Paul Reed
Sent: 06 August 2003 10:36
To: developers at bugzilla.org
Subject: Re: Template FOR loop


On 06 Aug 2003 at 10:26:42, Mark Ingram arranged the bits on my disk to say:

> and also, is it possible to do modulus calculations?
> ie, if there are 25 bugs, i want every 5th bug.
>
> ie.
>
> [% FOR (i = 0; i < num_bugs; i++) %]
> 	[% IF mod(i/5) = 0 %]
> 		Do something here<br>
> 	[% END %]
> [% END %]
>
> Is any of that possible?

Yes. But I don't think that syntax is right.

http://www.template-toolkit.org/docs/plain/index.html

Later,
Paul
------------------------------------------------------------------------
J. Paul Reed -- 0xDF8708F8 || preed at sigkill.com || web.sigkill.com/preed
To hold on to sanity too tight is insane.   -- Nick Falzone, Pushing Tin

I use PGP; you should use PGP too... if only to piss off John Ashcroft
-
To view or change your list settings, click here:
<http://bugzilla.org/cgi-bin/mj_wwwusr?user=mark.ingram@nexsan.com>





More information about the developers mailing list