summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorChris Pall <chrispall@gmail.com>2013-11-22 00:41:25 -0500
committerChris Pall <chrispall@gmail.com>2013-11-22 00:41:25 -0500
commite8954b34882859b311e6aada135005e01c0ed45e (patch)
tree8edd8992e7dc2a9f918ac74e3a1f7bac70f5c152 /lib
parent20b9c3829e6215b3a6e7de1222be9fcee332ca1b (diff)
downloadhandlebars.js-e8954b34882859b311e6aada135005e01c0ed45e.zip
handlebars.js-e8954b34882859b311e6aada135005e01c0ed45e.tar.gz
handlebars.js-e8954b34882859b311e6aada135005e01c0ed45e.tar.bz2
Update base.js
Give users the index for properties. When I am rendering a radio button I use key-value pairs, but I can't use either as unique identifiers because they likely contain invalid identifier characters. I added "first" as an index as well, but have no particular use case for first. Since there is no way to detect "last", I didn't add that property.
Diffstat (limited to 'lib')
-rw-r--r--lib/handlebars/base.js6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/handlebars/base.js b/lib/handlebars/base.js
index 56eb016..0bee138 100644
--- a/lib/handlebars/base.js
+++ b/lib/handlebars/base.js
@@ -101,7 +101,11 @@ function registerDefaultHelpers(instance) {
} else {
for(var key in context) {
if(context.hasOwnProperty(key)) {
- if(data) { data.key = key; }
+ if(data) {
+ data.key = key;
+ data.index = i;
+ data.first = (i == 0);
+ }
ret = ret + fn(context[key], {data: data});
i++;
}