On Thu, Nov 10, 2011 at 1:08 AM, Randal L. Schwartz <[email protected]>wrote:
> >>>>> "Ronald" == Ronald J Kimball <[email protected]> writes: > > Ronald> You should be outputing only the current address each time through > the > Ronald> loop. Here's an example: > > Ronald> [%- mylist = [ 'one' ] %] > Ronald> [%- mylist = [ 'one', 'two' ] %] > Ronald> [%- mylist = [ 'one', 'two', 'three' ] %] > Ronald> [%- FOREACH item IN mylist %] > Ronald> [%- IF loop.max() == 0 -%] > Ronald> [%- item %]. > Ronald> [%- ELSIF loop.last() -%] > Ronald> [%- IF loop.max() > 1 %]or [% END %][% item %]. > Ronald> [%- ELSE %][% item %], [% END %] > Ronald> [%- END %] > > Ronald> I put one of the [% END %]s at the end of the line to preserve the > trailing > Ronald> space character in the output. Adjust the style to your liking. > > I find this a little clearer: > > $ tpage > [% > BLOCK listem; > FOR item IN items; > item; > ", " IF loop.count < loop.max; > " or " IF loop.count == loop.max; > END; # FOR > END; # BLOCK > > FOR try = [0..5]; > try; ": <"; > INCLUDE listem items=[1..try]; > ">\n"; > END; # try > %] > ^D > 0: <> > 1: <1> > 2: <1 or 2> > 3: <1, 2 or 3> > 4: <1, 2, 3 or 4> > 5: <1, 2, 3, 4 or 5> > $ > > > -- > Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 > 0095 > <[email protected]> <URL:http://www.stonehenge.com/merlyn/> > Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc. > See http://methodsandmessages.posterous.com/ for Smalltalk discussion > I tried both the models but in frist model it printing like one,two,three address1, one ,two ,three address2 like it is adding one, two ,three at very address before. In the second model printing every thing exactly but it doesn't including , and or separators. it just printing address1 address2 address3 like that.
_______________________________________________ templates mailing list [email protected] http://mail.template-toolkit.org/mailman/listinfo/templates
