Re: [htmltmpl] Numeric loops
Brought to you by:
samtregar
From: Dan H. <dan...@re...> - 2007-04-30 00:36:05
|
On Sun, 2007-04-29 at 19:22 -0500, Karen wrote: > On 4/29/07, Dan Horne <dan...@re...> wrote: > > Is there a way to loop from a lower integer to an higher one? > For example, > say an article has a rating of 4. I'd like to loop from 1 to 4 > and print a > star at each iteration. The only way I can see of doing this > is create an > array ref in the perl coder and pass that to the template, > which seems a lot > of pointless effort > > > With (one assumes) a rating system with its own ceiling, though, you > could go with img src="blahblah/star<TMPL_VAR name="rating">.gif" or > what have you, and just have a set of graphics with star1.gif having > one star, star2.gif having two stars, and so forth. That would work. It's a shame that there isn't a regular loop construct, as I'd like a solution for all sorts of loop instances (Looping through the pagination indexes generated by Data::Page::Navigation for instance) Dan |