[Helma-user] New Additions to Template.js
Maksim Lin for technical support mailling lists
maksim_lin at ngv.vic.gov.au
Wed Apr 18 07:24:33 CEST 2007
Hi juerg,
Sorry for the slow reponse - have been away from office for a couple of days.
> > Being able to access the value of the loop counter would be
> very handy
> > - perhaps you could maek a builtin "counter variabel like velocity
> > uses?
>
> This is implemented now, on the base of the variable name,
> and in a way that even when you have two nested loops using
> the same variable name, it would still produce the expected
> result. This is how it works right now. Any suggestions are welcome:
>
> <% foreach $item in param.list %>
> <%= $item#index %>
> <%= $item#length %>
> <%= $item#isFirst %>
> <%= $item#isLast %>
> <% end %>
Eacellant! I'll grab the latest copy from the wiki and try it out.
> No variables are produced that are not needed. In fact, these
> special variables are discovered and then replaced with the
> proper code. Have a look at parseLoopVariables in the source
> code to see what I mean.
Yes I think I know what you mean. And I have to say I'm quite impressed with the speed tests I did with earlier versions of the JSTL so I'm keen to try them again with the new version.
> I have added two more experimental ones, not sure if they are needed:
> #even, #odd. I also just noticed they should probably be
> called #isEven, #isOdd?
I guess I might use them to do nice table row colours with class atrribute and CSS...
> > 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.
> > Also Juerg, would it be possible to agree on freezing on a
> particular
> > version of the syntax? as I currently have a project
> underway where I
> > am using JTSL and another about to begin and would like to have a
> > 'stable' version on which I could depend on rather then
> having to keep
> > going back and updating my templates.
>
> I understand... But you should also understand that
> Template.js was allways there to be a testbed for me to try
> out templating stuff. As the old version works for your
> project, there is actually no real need to update it, except
> that if you want to be able to take advante of the new stuff.
>
> Having said that, I am not intersted in too many changes
> myself either, as I have projects based on it too. I just
> felt the need to make some changes in the design decisions,
> and tried to make this with as little impact on existing
> templates as possible.
That's fair enough Juerg you did say several times that it was just for your experimentation - I just found them so useful that I went ahead ans started using them anyway. Its good to know that it should be fairly stabel form now on and your right - I will just keep using the version I need for particaulr apps, its just it will be easier to stick to one version over some time.
> The things that I broke:
>
> - Nested content is gone. No more <% >...</%>. Is that bad?
> Should it be back? It wouldn't be hard. As Hannes said, the
No - I personally never used (or will) nested content.
> nested stuff could be passed in param.nested. The only place
> I've used this was for sub templates, and that now works in
> the Helma way. Which brings us to:
> - Sub Templates: Ditto
> - Local variable names need to have $ preprended.
>
> Note that although I don't use the parantheses for "foreach",
> "if", "elseif" any longer, you still can if you like that
> syntax better.
>
> That's it for now.
>
> The site is update with new explanations and code.
Brillant! - thanks again for all your hard work implementing JSTLs Juerg.
Maks.
> 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