diff --git a/src/Latte/Essential/Nodes/IncludeFileNode.php b/src/Latte/Essential/Nodes/IncludeFileNode.php index 8c8fcf4b5..93c64f2e7 100644 --- a/src/Latte/Essential/Nodes/IncludeFileNode.php +++ b/src/Latte/Essential/Nodes/IncludeFileNode.php @@ -31,8 +31,6 @@ class IncludeFileNode extends StatementNode public static function create(Tag $tag): static { - $tag->outputMode = $tag::OutputRemoveIndentation; - $tag->expectArguments(); $node = new static; $tag->parser->tryConsumeTokenBeforeUnquotedString('file'); @@ -43,6 +41,8 @@ public static function create(Tag $tag): static if ($stream->tryConsume('with')) { $stream->consume('blocks'); $node->mode = 'includeblock'; + } else { + $tag->outputMode = $tag::OutputRemoveIndentation; } $stream->tryConsume(','); diff --git a/tests/tags/expected/include.with-blocks.html b/tests/tags/expected/include.with-blocks.html index b3105d7bc..af0fa4e22 100644 --- a/tests/tags/expected/include.with-blocks.html +++ b/tests/tags/expected/include.with-blocks.html @@ -1,4 +1,3 @@ - Parent: main/includeblock diff --git a/tests/tags/expected/include.with-blocks.php b/tests/tags/expected/include.with-blocks.php index 240a99ea0..930439809 100644 --- a/tests/tags/expected/include.with-blocks.php +++ b/tests/tags/expected/include.with-blocks.php @@ -8,8 +8,15 @@ final class Template%a% extends Latte\Runtime\Template public function main(array $ʟ_args): void { %A% - $this->createTemplate(true ? 'inc' : '', $this->params, 'includeblock')->renderToContentType('html') /* line %d% */; echo "\n"; $this->renderBlock('test', [], 'html') /* line %d% */; } + + + public function prepare(): array + { +%A% + $this->createTemplate(true ? 'inc' : '', $this->params, 'includeblock')->renderToContentType('html') /* line %d% */; +%A% + } } diff --git a/tests/tags/expected/inheritance.1.php b/tests/tags/expected/inheritance.1.php index 5549edcf7..198b271d0 100644 --- a/tests/tags/expected/inheritance.1.php +++ b/tests/tags/expected/inheritance.1.php @@ -12,7 +12,6 @@ final class Template%a% extends Latte\Runtime\Template public function main(array $ʟ_args): void { %A% - $this->createTemplate('inc', $this->params, 'includeblock')->renderToContentType('html') /* line %d% */; echo "\n"; $this->renderBlock('title', get_defined_vars()) /* line %d% */; echo ' @@ -33,6 +32,7 @@ public function prepare(): array } $this->parentName = 'parent'; $this->createTemplate('inc', $this->params, "import")->render() /* line %d% */; + $this->createTemplate('inc', $this->params, 'includeblock')->renderToContentType('html') /* line %d% */; return get_defined_vars(); } diff --git a/tests/tags/include.with-blocks.nodes.phpt b/tests/tags/include.with-blocks.nodes.phpt index 3b81359c8..54791abb3 100644 --- a/tests/tags/include.with-blocks.nodes.phpt +++ b/tests/tags/include.with-blocks.nodes.phpt @@ -13,7 +13,6 @@ require __DIR__ . '/../bootstrap.php'; Assert::match(<<<'XX' Template: - Fragment: Fragment: IncludeFile: String: @@ -23,4 +22,5 @@ Assert::match(<<<'XX' Filter: Identifier: name: trim + Fragment: XX, exportTraversing('{include file.latte with blocks|trim}'));