The documentation for the template class and evaluate method may have
a small omission.
When evaluating a template, you don't necessarily need to use an
object literal. You can use an array as well - provided you use
numbers when creating the template:
[code]
//templates
var t1 = new Template('There are #{0} days in #{1}');
var t2 = new Template('There are #{days} days in #{year}');
//template values
var v1 = [365,2007];
var v2 = {days:365,year:2007};
//works
t1.evaluate(v1); //There are 365 days in 2007
t2.evaluate(v2); //There are 365 days in 2007
//doesn't work
t1.evaluate(v2); //There are days in
t2.evaluate(v1); //There are days in
[/code]
You can't interchange between the two, but I've discovered situations
where I've needed both an object and an array and they both work
equally well.
http://prototypejs.org/api/template
http://prototypejs.org/api/template/evaluate
Thanks,
Jon
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Prototype: Core" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/prototype-core?hl=en
-~----------~----~----~----~------~----~------~--~---