Skip to content

Commit

Permalink
{exitIf} must not be in prepare()
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Nov 11, 2023
1 parent af8c0aa commit 48fd9c1
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/Latte/Essential/Nodes/JumpNode.php
Expand Up @@ -31,6 +31,10 @@ class JumpNode extends StatementNode
public static function create(Tag $tag): static
{
$tag->expectArguments();
$tag->outputMode = $tag->name === 'exitIf' // to not be in prepare()
? $tag::OutputRemoveIndentation
: $tag::OutputNone;

for (
$parent = $tag->parent;
$parent?->node instanceof IfNode || $parent?->node instanceof IfContentNode;
Expand Down
2 changes: 1 addition & 1 deletion tests/tags/exitIf.nodes.phpt
Expand Up @@ -13,11 +13,11 @@ require __DIR__ . '/../bootstrap.php';

Assert::match(<<<'XX'
Template:
Fragment:
Fragment:
Jump:
Variable:
name: a
Fragment:
Text:
content: ' '
Block:
Expand Down
18 changes: 18 additions & 0 deletions tests/tags/exitIf.phpt
Expand Up @@ -27,6 +27,24 @@ Assert::exception(
);


$template = <<<'XX'
{exitIf true}
c
XX;

Assert::match(
<<<'XX'
%A%
{
if (true) /* line 1 */ return;
echo 'c';
}
%A%
XX,
$latte->compile($template),
);


$template = <<<'XX'
a
{exitIf true}
Expand Down

0 comments on commit 48fd9c1

Please sign in to comment.