Allow empty key name in each iteration

Fixes #1021
This commit is contained in:
kpdecker
2015-08-01 16:04:40 -05:00
parent 2a851067b9
commit 1bb640be41
2 changed files with 11 additions and 1 deletions
+1 -1
View File
@@ -151,7 +151,7 @@ function registerDefaultHelpers(instance) {
// We're running the iterations one step out of sync so we can detect
// the last iteration without have to scan the object twice and create
// an itermediate keys array.
if (priorKey) {
if (priorKey !== undefined) {
execIteration(priorKey, i - 1);
}
priorKey = key;
+10
View File
@@ -172,4 +172,14 @@ describe('Regressions', function() {
var result = template(context);
equals(result, 'foo');
});
it('GH-1021: Each empty string key', function() {
var data = {
'': 'foo',
'name': 'Chris',
'value': 10000
};
shouldCompileTo('{{#each data}}Key: {{@key}}\n{{/each}}', {data: data}, 'Key: \nKey: name\nKey: value\n');
});
});