Skip to content

Commit e8954b3

Browse files
committed
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.
1 parent 20b9c38 commit e8954b3

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/handlebars/base.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,11 @@ function registerDefaultHelpers(instance) {
101101
} else {
102102
for(var key in context) {
103103
if(context.hasOwnProperty(key)) {
104-
if(data) { data.key = key; }
104+
if(data) {
105+
data.key = key;
106+
data.index = i;
107+
data.first = (i == 0);
108+
}
105109
ret = ret + fn(context[key], {data: data});
106110
i++;
107111
}

0 commit comments

Comments
 (0)