Skip to content

Commit

Permalink
{include with blocks} does not end the head
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Apr 6, 2024
1 parent 1ab054b commit 16de2dd
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/Latte/Essential/Nodes/IncludeFileNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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(',');
Expand Down
1 change: 0 additions & 1 deletion tests/tags/expected/include.with-blocks.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@



Parent: main/includeblock
9 changes: 8 additions & 1 deletion tests/tags/expected/include.with-blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -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%
}
}
2 changes: 1 addition & 1 deletion tests/tags/expected/inheritance.1.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 '
Expand All @@ -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();
}

Expand Down
2 changes: 1 addition & 1 deletion tests/tags/include.with-blocks.nodes.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ require __DIR__ . '/../bootstrap.php';

Assert::match(<<<'XX'
Template:
Fragment:
Fragment:
IncludeFile:
String:
Expand All @@ -23,4 +22,5 @@ Assert::match(<<<'XX'
Filter:
Identifier:
name: trim
Fragment:
XX, exportTraversing('{include file.latte with blocks|trim}'));

0 comments on commit 16de2dd

Please sign in to comment.