diff --git a/src/language-handlebars/printer-glimmer.js b/src/language-handlebars/printer-glimmer.js index 9261d0a3fc14..c73186b51683 100644 --- a/src/language-handlebars/printer-glimmer.js +++ b/src/language-handlebars/printer-glimmer.js @@ -106,11 +106,12 @@ function print(path, options, print) { const isElseIf = pp && pp.inverse && + pp.inverse.body.length === 1 && pp.inverse.body[0] === n && pp.inverse.body[0].path.parts[0] === "if"; const hasElseIf = n.inverse && - n.inverse.body[0] && + n.inverse.body.length === 1 && n.inverse.body[0].type === "BlockStatement" && n.inverse.body[0].path.parts[0] === "if"; const indentElse = hasElseIf ? a => a : indent; diff --git a/tests/glimmer/__snapshots__/jsfmt.spec.js.snap b/tests/glimmer/__snapshots__/jsfmt.spec.js.snap index 7580902e4984..d5c1a9d20588 100644 --- a/tests/glimmer/__snapshots__/jsfmt.spec.js.snap +++ b/tests/glimmer/__snapshots__/jsfmt.spec.js.snap @@ -948,9 +948,11 @@ printWidth: 80 {{/if}} {{#if a}} a -{{else if c}} - c -e +{{else}} + {{#if c}} + c + {{/if}} + e {{/if}} ================================================================================ `; @@ -1107,9 +1109,11 @@ singleQuote: true {{/if}} {{#if a}} a -{{else if c}} - c -e +{{else}} + {{#if c}} + c + {{/if}} + e {{/if}} ================================================================================ `;