[Helma-user] New Additions to Template.js

Maksim Lin for technical support mailling lists maksim_lin at ngv.vic.gov.au
Mon Apr 23 10:16:02 CEST 2007


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: helma-user-bounces at helma.org 
> [mailto:helma-user-bounces at helma.org] 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
> Helma-user at helma.org
> http://helma.org/mailman/listinfo/helma-user
> 
> 
> 


More information about the Helma-user mailing list