cleanup statements if they only contain whitespace
This commit is contained in:
parent
60a2cc487e
commit
d72173d3fe
3 changed files with 15 additions and 0 deletions
|
@ -228,6 +228,14 @@ const buildBlock = (
|
|||
block: Block,
|
||||
mapped: (string | builders.Doc[] | builders.DocCommand)[]
|
||||
): builders.Doc => {
|
||||
// if the content is empty or whitespace only.
|
||||
if (block.content.match(/^\s*$/)) {
|
||||
return builders.fill([
|
||||
path.call(print, "nodes", block.start.id),
|
||||
builders.softline,
|
||||
path.call(print, "nodes", block.end.id),
|
||||
]);
|
||||
}
|
||||
if (block.containsNewLines) {
|
||||
return builders.group([
|
||||
path.call(print, "nodes", block.start.id),
|
||||
|
|
2
test/cases/statement_empty_block/expected.html
Normal file
2
test/cases/statement_empty_block/expected.html
Normal file
|
@ -0,0 +1,2 @@
|
|||
{% block title %}
|
||||
{% endblock %}
|
5
test/cases/statement_empty_block/input.html
Normal file
5
test/cases/statement_empty_block/input.html
Normal file
|
@ -0,0 +1,5 @@
|
|||
{% block title %}
|
||||
|
||||
|
||||
|
||||
{% endblock %}
|
Loading…
Reference in a new issue