Template FOR loop

vladd jocuri at softhome.net
Thu Aug 7 00:01:26 UTC 2003


Hello,

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

[% FOREACH bug_id = [ 0 .. num_bugs ] %]
	...
[% END %]

Thanks,
Vlad.

>
> 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>
>
>
> -
> To view or change your list settings, click here:
> <http://bugzilla.org/cgi-bin/mj_wwwusr?user=jocuri@softhome.net>




More information about the developers mailing list