diff --git a/src/parse/state/mustache.ts b/src/parse/state/mustache.ts index 6e44f7c15e..0a255b1256 100644 --- a/src/parse/state/mustache.ts +++ b/src/parse/state/mustache.ts @@ -6,7 +6,7 @@ import { Parser } from '../index'; import { Node } from '../../interfaces'; function trimWhitespace(block: Node, trimBefore: boolean, trimAfter: boolean) { - if (!block.children) return; // AwaitBlock + if (!block.children || block.children.length === 0) return; // AwaitBlock const firstChild = block.children[0]; const lastChild = block.children[block.children.length - 1]; diff --git a/test/validator/samples/empty-block-dev/input.html b/test/validator/samples/empty-block-dev/input.html index 53e2ca8333..32b892d470 100644 --- a/test/validator/samples/empty-block-dev/input.html +++ b/test/validator/samples/empty-block-dev/input.html @@ -1,3 +1,5 @@ {{#each things as thing}} -{{/each}} \ No newline at end of file +{{/each}} + +{{#each things as thing}}{{/each}} \ No newline at end of file diff --git a/test/validator/samples/empty-block-dev/warnings.json b/test/validator/samples/empty-block-dev/warnings.json index 6cbc567ada..54584bf135 100644 --- a/test/validator/samples/empty-block-dev/warnings.json +++ b/test/validator/samples/empty-block-dev/warnings.json @@ -1,8 +1,18 @@ -[{ - "message": "Empty block", - "loc": { - "line": 1, - "column": 0 +[ + { + "message": "Empty block", + "loc": { + "line": 1, + "column": 0 + }, + "pos": 0 }, - "pos": 0 -}] \ No newline at end of file + { + "message": "Empty block", + "loc": { + "line": 5, + "column": 0 + }, + "pos": 38 + } +] \ No newline at end of file diff --git a/test/validator/samples/empty-block-prod/input.html b/test/validator/samples/empty-block-prod/input.html index 53e2ca8333..32b892d470 100644 --- a/test/validator/samples/empty-block-prod/input.html +++ b/test/validator/samples/empty-block-prod/input.html @@ -1,3 +1,5 @@ {{#each things as thing}} -{{/each}} \ No newline at end of file +{{/each}} + +{{#each things as thing}}{{/each}} \ No newline at end of file