handlebars.js
handlebars.js copied to clipboard
Whitespace issue when using else if
Hi,
When I run the following example (please note the indentation of the inner block and that an else-if is used)
{{#if test}}
{{#if test.a}}
hihi
{{else if test.b}}
hoho
{{else}}
huhu
{{/if}}
hehe
{{/if}}
the result I get for { test: { c: true, }, }
is that hehe is intended twice:
huhu
hehe
However, when I try the same example with a nested if-else block instead the else if,
{{#if test}}
{{#if test.a}}
hihi
{{else}}
{{#if test.b}}
hoho
{{else}}
huhu
{{/if}}
{{/if}}
hehe
{{/if}}
I get the result I would expect for both cases, namely that both words are indented just once:
huhu
hehe
You can test that for yourself in the handlebars playground.
So I think I've found a Handlebars bug here. Or am I just doing something wrong?
I'm facing the same issue in a different context.
I am also facing this problem in my project. Does anyone have any idea on how to fix this bug?
I am also facing this problem in my project. Does anyone have any idea on how to fix this bug?
The only solution that worked for me was not using else if at all but using nested if‘s as can be seen in my second example above.
I am also facing this problem in my project. Does anyone have any idea on how to fix this bug?
The only solution that worked for me was not using else if at all but using nested if‘s as can be seen in my second example above.
Yes it's a shame to have to use this syntax to fix the bug. I would like to understand where the problem comes from :s