diff --git a/src/printer.ts b/src/printer.ts index 2e8a1f4..5ec8d3f 100644 --- a/src/printer.ts +++ b/src/printer.ts @@ -44,7 +44,7 @@ const printExpression = (node: Expression): builders.Doc => { ); return node.preNewLines > 1 - ? builders.group([builders.hardline, builders.trim, expression]) + ? builders.group([builders.trim, builders.hardline, expression]) : expression; }; @@ -79,7 +79,7 @@ const printCommentBlock = (node: Node): builders.Doc => { }); return node.preNewLines > 1 - ? builders.group([builders.hardline, builders.trim, comment]) + ? builders.group([builders.trim, builders.hardline, comment]) : comment; }; @@ -162,7 +162,7 @@ export const embed: Printer["embed"] = ( const block = buildBlock(path, print, node as Block, mapped); return node.preNewLines > 1 - ? builders.group([builders.hardline, builders.trim, block]) + ? builders.group([builders.trim, builders.hardline, block]) : block; } return [...mapped, builders.hardline]; diff --git a/test/cases/newline_between/expected.html b/test/cases/newline_between/expected.html index ff17c82..fb87c1c 100644 --- a/test/cases/newline_between/expected.html +++ b/test/cases/newline_between/expected.html @@ -28,3 +28,19 @@ {% else %}
  • no users found
  • {% endfor %} + +{% macro input(name, value='', type='text', size=20) %} + + {{ my_variable|default('my_variable is not defined') }} + + {% for city, items in users|groupby("city") %} +
  • + {{ city }} + +
  • + {% endfor %} +{% endmacro %} diff --git a/test/cases/newline_between/input.html b/test/cases/newline_between/input.html index 2704213..10d3f64 100644 --- a/test/cases/newline_between/input.html +++ b/test/cases/newline_between/input.html @@ -37,3 +37,17 @@
  • no users found
  • {% endfor %} + +{% macro input(name, value='', type='text', size=20) %} + +{{ my_variable|default('my_variable is not defined') }} + +{% for city, items in users|groupby("city") %} +
  • {{ city }} + +
  • +{% endfor %} + +{% endmacro %} \ No newline at end of file