Hello Martijn,

Tuesday, November 05, 2002, 4:00:31 PM, you wrote:

MvdB> On Tuesday 05 November 2002 12:31, Philip S Tellis wrote:
>> Sometime Today, Martijn van den Burg assembled some asciibets to say:
>> > I started using the __counter__ variable to dynamically build
>> > JavaScript arrays in my HTML. Unfortunately __counter__ starts
>> > counting at 1 (one), resulting in my first (i.e. index zero) array
>> > elements not being initialized.
>>
>> Isn't it just easier to use arr[<tmpl_var __counter__> - 1]; ?

MvdB> Easier, yes. But it results in unelegant (if not to say ugly) and less clear 
MvdB> code:

MvdB> fruits[1 - 1] = new fruitObj('apple','red');

MvdB> <Martijn />

Instead of __counter__ you may use your own counter:

foreach my $i (@arr) {
        $i -> {my_counter} = whatever_you_want;
}
$template -> param( { array => \@arr } );

-- 
Best regards,
 Aleksey



-------------------------------------------------------
This sf.net email is sponsored by: See the NEW Palm 
Tungsten T handheld. Power & Color in a compact size!
http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0001en
_______________________________________________
Html-template-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/html-template-users

Reply via email to