You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
var handlebars = require('handlebars');
var template = handlebars.compile(
'{{#each files.primary as |file|}}\n\
{{{file.oldFile}}} {{{file.newFile}}}\n\
{{/each}}\n\
{{#if files.secondary.length}}\n\
{{#each files.secondary as |file|}}\n\
{{{file.oldFile}}} {{{file.newFile}}}\n\
{{/each}}\n\
{{/if}}');
var config = {
files: {
primary: [ { oldFile: 'old.txt', newFile: 'new.txt' } ],
secondary: [ { oldFile: 'old.txt', newFile: 'new.txt' } ] }
};
var rslt = template(config);
console.log(rslt);
Run in node, it produces this console output:
undefined:6
+ ((stack1 = alias1(((stack1 = blockParams[0][0]) != null ? stack1.oldFile : stack1), depth0)) != null ? stack1 : "")
^
TypeError: Cannot read property '0' of undefined
at eval (eval at createFunctionContext (/www.nls.com/nodejs/usr-share-nodejs/www/util/printkit-config/node_modules/handlebars/dist/cjs/handlebars/compiler/javascript-compiler.js:254:23), <anonymous>:6:47)
at prog (/www.nls.com/nodejs/usr-share-nodejs/www/util/printkit-config/node_modules/handlebars/dist/cjs/handlebars/runtime.js:219:12)
at execIteration (/www.nls.com/nodejs/usr-share-nodejs/www/util/printkit-config/node_modules/handlebars/dist/cjs/handlebars/helpers/each.js:51:19)
at Object.<anonymous> (/www.nls.com/nodejs/usr-share-nodejs/www/util/printkit-config/node_modules/handlebars/dist/cjs/handlebars/helpers/each.js:61:13)
at eval (eval at createFunctionContext (/www.nls.com/nodejs/usr-share-nodejs/www/util/printkit-config/node_modules/handlebars/dist/cjs/handlebars/compiler/javascript-compiler.js:254:23), <anonymous>:5:34)
at Object.prog [as fn] (/www.nls.com/nodejs/usr-share-nodejs/www/util/printkit-config/node_modules/handlebars/dist/cjs/handlebars/runtime.js:219:12)
at Object.<anonymous> (/www.nls.com/nodejs/usr-share-nodejs/www/util/printkit-config/node_modules/handlebars/dist/cjs/handlebars/helpers/if.js:19:22)
at Object.eval (eval at createFunctionContext (/www.nls.com/nodejs/usr-share-nodejs/www/util/printkit-config/node_modules/handlebars/dist/cjs/handlebars/compiler/javascript-compiler.js:254:23), <anonymous>:6:32)
at main (/www.nls.com/nodejs/usr-share-nodejs/www/util/printkit-config/node_modules/handlebars/dist/cjs/handlebars/runtime.js:173:32)
at ret (/www.nls.com/nodejs/usr-share-nodejs/www/util/printkit-config/node_modules/handlebars/dist/cjs/handlebars/runtime.js:176:12)
Any of these changes cause the error to go away:
Removing the first #each clause from the template
Removing the #if clause from the template
Removing the {{{file.oldFile}}} expansion from the second #each clause, or replacing it with {{oldFile}}
Here's a fiddle with essentially the same example. The console output reports a slightly different error (in Firefox: TypeError: blockParams is undefined).
The text was updated successfully, but these errors were encountered:
Does this issue still exist? If it had the same cause as #1250, it should have been fixed in the meantime (i.e. since 4.0.6). If it is related to #1300, it is probably still there. Could anybody check?
Here's a short example that generates the error:
Run in node, it produces this console output:
Any of these changes cause the error to go away:
#each
clause from the template#if
clause from the template{{{file.oldFile}}}
expansion from the second#each
clause, or replacing it with{{oldFile}}
Here's a fiddle with essentially the same example. The console output reports a slightly different error (in Firefox: TypeError: blockParams is undefined).
The text was updated successfully, but these errors were encountered: