Hi,
I'm trying to generate a file using the
Template module.
I have an array of names and need to produce a comma separated list where each name appears twice in the format ".$name($name)":
@myarray = qw(A B C D E);
should produce:
.A(A),
.B(B),
.C(C),
.D(D),
.E(E)
Please note that the last line does not end in a comma.
If the problem with the last trailing comma would not exits I simple could use
FOREACH:
[% FOREACH n in names %]
.[% n %]([% n %]),
[%- END %]
Also I know about the possibility to use
.join():
[% names.join(",\n") %]
which does not allow me to use the names twice.
I tried some combinations and checked the manual but could not find a solution yet. Can someone with more experience with Template point me in the right direction?
Thanks