[Zope-dev] Repeating a piece of HTML code

Duncan Booth duncan@rcp.co.uk
Fri, 2 Jun 2000 14:19:41 +0000


> > <dtml-in expr="_.range(0, movie_rating)">
> >   <img SRC="star.gif" height=15 width=15>
> > </dtml-in>
> > 
> > Replace movie_rating with the variable that represents the movie rating.
> 
> What about <dtml-var "'*' * movie_rating"> ?
> 

Fine, except that he wants the <img> tag repeated the appropriate 
number of times. Try putting the tag into the dtml-var statement 
and you get something along the lines of (untested):

  <dtml-var "('<img src=%sstart.gif%s height=15 width=15>' % 
(_.chr(34), _.chr(34))) * movie_rating">

at which point the dtml-in starts to look more appealing.

Of course if you rename star.gif as star_gif you could try:
 <dtml-var "start_gif.tag() * movie_rating">
which has a certain neatness.


-- 
Duncan Booth                                             duncan@dales.rmplc.co.uk
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?
http://dales.rmplc.co.uk/Duncan