diff --git a/src/language-handlebars/printer-glimmer.js b/src/language-handlebars/printer-glimmer.js index cce610c7..9eb40b31 100644 --- a/src/language-handlebars/printer-glimmer.js +++ b/src/language-handlebars/printer-glimmer.js @@ -47,9 +47,14 @@ function print(path, options, print) { ); } case "ElementNode": { - const isVoid = voidTags.indexOf(n.tag) !== -1; - const closeTag = isVoid ? concat([" />", softline]) : ">"; + const tagFirstChar = n.tag[0]; + const isLocal = n.tag.indexOf(".") !== -1; + const isGlimmerComponent = + tagFirstChar.toUpperCase() === tagFirstChar || isLocal; const hasChildren = n.children.length > 0; + const isVoid = + (isGlimmerComponent && !hasChildren) || voidTags.indexOf(n.tag) !== -1; + const closeTag = isVoid ? concat([" />", softline]) : ">"; const getParams = (path, print) => indent( concat([ diff --git a/tests/html_glimmer/__snapshots__/jsfmt.spec.js.snap b/tests/html_glimmer/__snapshots__/jsfmt.spec.js.snap index ab84adb8..7765ebca 100644 --- a/tests/html_glimmer/__snapshots__/jsfmt.spec.js.snap +++ b/tests/html_glimmer/__snapshots__/jsfmt.spec.js.snap @@ -135,9 +135,16 @@ exports[`block-statement.hbs - glimmer-verify 1`] = ` `; exports[`component.hbs - glimmer-verify 1`] = ` - + {{@greeting}}, {{@name}}! +
+ + hello + + + + @@ -146,11 +153,18 @@ exports[`component.hbs - glimmer-verify 1`] = `
Hello
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - + {{@greeting}} , {{@name}} ! +
+ + + hello + + + diff --git a/tests/html_glimmer/component.hbs b/tests/html_glimmer/component.hbs index 69cd3d2d..5f8860f1 100644 --- a/tests/html_glimmer/component.hbs +++ b/tests/html_glimmer/component.hbs @@ -1,6 +1,13 @@ - + {{@greeting}}, {{@name}}! +
+ + hello + + + +