Skip to content

Commit

Permalink
allow {exitIf} in {define} (#334)
Browse files Browse the repository at this point in the history
  • Loading branch information
vvoody- authored and dg committed Aug 7, 2023
1 parent b9c9433 commit be11600
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Latte/Essential/Nodes/JumpNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public static function create(Tag $tag): static
$allowed = match ($tag->name) {
'breakIf', 'continueIf' => ['for', 'foreach', 'while'],
'skipIf' => ['foreach'],
'exitIf' => ['block', null],
'exitIf' => ['block', 'define', null],
};
for (
$parent = $tag->parent;
Expand Down
29 changes: 29 additions & 0 deletions tests/tags/exitIf.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,32 @@ Assert::match(
XX,
$latte->compile($template),
);


$template = <<<'XX'
{define foo}
a
{exitIf true}
b
{exitIf false}
c
{/define}
XX;

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

0 comments on commit be11600

Please sign in to comment.