fix indentation after empty lines

This commit is contained in:
davidodenwald 2023-05-14 11:26:48 +02:00
parent c854cfd82d
commit fd332a60e1
3 changed files with 33 additions and 3 deletions

View file

@ -44,7 +44,7 @@ const printExpression = (node: Expression): builders.Doc => {
); );
return node.preNewLines > 1 return node.preNewLines > 1
? builders.group([builders.hardline, builders.trim, expression]) ? builders.group([builders.trim, builders.hardline, expression])
: expression; : expression;
}; };
@ -79,7 +79,7 @@ const printCommentBlock = (node: Node): builders.Doc => {
}); });
return node.preNewLines > 1 return node.preNewLines > 1
? builders.group([builders.hardline, builders.trim, comment]) ? builders.group([builders.trim, builders.hardline, comment])
: comment; : comment;
}; };
@ -162,7 +162,7 @@ export const embed: Printer<Node>["embed"] = (
const block = buildBlock(path, print, node as Block, mapped); const block = buildBlock(path, print, node as Block, mapped);
return node.preNewLines > 1 return node.preNewLines > 1
? builders.group([builders.hardline, builders.trim, block]) ? builders.group([builders.trim, builders.hardline, block])
: block; : block;
} }
return [...mapped, builders.hardline]; return [...mapped, builders.hardline];

View file

@ -28,3 +28,19 @@
{% else %} {% else %}
<li><em>no users found</em></li> <li><em>no users found</em></li>
{% endfor %} {% endfor %}
{% macro input(name, value='', type='text', size=20) %}
{{ my_variable|default('my_variable is not defined') }}
{% for city, items in users|groupby("city") %}
<li>
{{ city }}
<ul>
{% for user in items %}
<li>{{ user.name }}</li>
{% endfor %}
</ul>
</li>
{% endfor %}
{% endmacro %}

View file

@ -37,3 +37,17 @@
<li><em>no users found</em></li> <li><em>no users found</em></li>
{% endfor %} {% endfor %}
{% macro input(name, value='', type='text', size=20) %}
{{ my_variable|default('my_variable is not defined') }}
{% for city, items in users|groupby("city") %}
<li>{{ city }}
<ul>{% for user in items %}
<li>{{ user.name }}
{% endfor %}</ul>
</li>
{% endfor %}
{% endmacro %}