in reply to Format and Join an Array in a Template
It looks like you want to do the same thing to each item in the list except the last item, right? I think:
[% FOREACH n in names.slice(0,-2) %] .[% n %]([% n %]), [%- END %] .[% names.last %]([% names.last %])
Would do what you want. See Template::Manual::VMethods for more. The above is untested, so play around until it actually works.
Update: s/slice(0,-1)/slice(0,-2)/
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Format and Join an Array in a Template
by ikegami (Patriarch) on Jun 19, 2009 at 17:26 UTC | |
|
Re^2: Format and Join an Array in a Template
by mscharrer (Hermit) on Jun 19, 2009 at 17:09 UTC | |
by ikegami (Patriarch) on Jun 19, 2009 at 17:26 UTC |