Re: New Additions to Template.js

"Maksim Lin for technical support mailling lists" <[email protected]>
Newsgroups gmane.comp.java.helma.general
Message-ID <[email protected]>
Hi Juerg,

I think it would be good to have both index and key, as the index you would want if you were pritning say numbers next to each item (say in a table).
But I think if its going to be too much trouble don't worry about it for now - if I find I really need it in the future I should have a go at adding it myself :-)
Actually at the moment I am having another go at learning to use skins again and seeing if I can do my normal dev in helmas 'default' rendering mode.

Maks.

> -----Original Message-----
> From: [email protected] 
> [mailto:[email protected]] On Behalf Of Juerg Lehni
> Sent: Sunday, 22 April 2007 15:30
> To: Helma User Mailing List
> Subject: Re: [Helma-user] New Additions to Template.js
> 
> Hi Maksim,
> 
> >>> Also I think it is useful to have functionality to iterate over 
> >>> objects (hashs) as well as Arrays, since often I want to 
> didpaly a 
> >>> html table or list of values of an object and I don't worry about 
> >>> ordering/sorting it.
> >>
> >> That's good to know, I will add it again then. #length and #isLast 
> >> will not work on these loops though.
> >
> > As expected so no probs there.
> 
> I started to look into this, and realized it will not be as 
> straight forward as I wished. The problem is that for hashes, 
> we have key - value pairs, while for arrays we have numeric 
> indices and values. Now for a hash, the loop variable 
> probably should contain the value, and $variable#index should 
> be the key, instead of the numeric index, right? Or should we 
> add #key, and #index would still give a number?
> 
> I'm not sure yet how to implement this nicely, as I only know 
> at runtime wether a loop object is an array or a hash object. 
> And at that time, the loop is already hardcoded, so I cannot 
> switch between for-in and normal for loops...
> 
> Jürg
> _______________________________________________
> Helma-user mailing list
> [email protected]
> http://helma.org/mailman/listinfo/helma-user
> 
> 
>
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.