Skip to content

Commit

Permalink
Update base.js
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
cgp committed Nov 22, 2013
1 parent 20b9c38 commit e8954b3
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/handlebars/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
}
Expand Down

0 comments on commit e8954b3

Please sign in to comment.