Re: [template] please help me in template tool kit module

Ronald J Kimball <rkimball-jkI2qz8QNLsmlAP/[email protected]>
Newsgroups gmane.comp.lang.perl.modules.template-toolkit
Message-ID <CAEnkCGRfSbez6RYhyu=DUqQ+3Eftg_szeML1QRh6-M30TVY5-g@mail.gmail.com>
You should be outputing only the current address each time through the
loop.  Here's an example:

[%- mylist = [ 'one' ] %]
[%- mylist = [ 'one', 'two' ] %]
[%- mylist = [ 'one', 'two', 'three' ] %]
[%- FOREACH item IN mylist %]
  [%- IF loop.max() == 0 -%]
    [%- item %].
  [%- ELSIF loop.last() -%]
    [%- IF loop.max() > 1 %]or [% END %][% item %].
  [%- ELSE %][% item %], [% END %]
[%- END %]

I put one of the [% END %]s at the end of the line to preserve the trailing
space character in the output.  Adjust the style to your liking.

Ronald

_______________________________________________
templates mailing list
[email protected]
http://mail.template-toolkit.org/mailman/listinfo/templates
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.