handlebars.js
handlebars.js copied to clipboard
Whitespace control in one {{else if}} branch also affects a different branch
In this test case, I’ve used whitespace control on just one side of just one {{else if}}
branch:
const Handlebars = require("handlebars");
const source = `\
{{#if a}}
a
{{else if b}}
b
{{else if c}}
c
{{~else if d}}
d
{{else if e}}
e
{{else if f}}
f
{{else if g}}
g
{{/if}}
`;
const template = Handlebars.compile(source);
console.log(JSON.stringify(template({a: 1})));
console.log(JSON.stringify(template({b: 1})));
console.log(JSON.stringify(template({c: 1})));
console.log(JSON.stringify(template({d: 1})));
console.log(JSON.stringify(template({e: 1})));
console.log(JSON.stringify(template({f: 1})));
console.log(JSON.stringify(template({g: 1})));
But two of the outputs are affected:
"a\n"
"b\n"
"c"
"d\n"
"e"
"f\n"
"g\n"
I expect the whitespace control to only affect "c"
, so "e"
should be "e\n"
.
Using Handlebars 4.7.8 on Node.js 20.11.1.