Skip to content

Commit

Permalink
Merge branch 'b-7.2.x' into b-8.0.x
Browse files Browse the repository at this point in the history
  • Loading branch information
tkcreateit committed Sep 6, 2024
2 parents 4a4aa25 + 6f647e3 commit 5878039
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Node/IfContentNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ public function compile(Compiler $compiler): void
$compiler->raw(");\n");

$compiler
->write("if(")
->subcompile($this->getNode('variable'), false)
->write(") { \n")
->subcompile($this->getNode('body'))
->write(" } \n")
->write("unset(")->subcompile($this->getNode('variable'))->raw(");\n");
}
}
4 changes: 4 additions & 0 deletions tests/Unit/Node/IfContentNodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ public static function getOxidTwigTests(): array
$tests[] = [$node, <<<EOF
// line 1
\$context["foo"] = \$this->extensions['$ifContentExtensionClass']->getContent("oxsomething", null);
if(\$context["foo"]) {
echo "Lorem Ipsum";
}
unset(\$context["foo"]);
EOF
];
Expand All @@ -59,7 +61,9 @@ public static function getOxidTwigTests(): array
$tests[] = [$node, <<<EOF
// line 1
\$context["foo"] = \$this->extensions['$ifContentExtensionClass']->getContent(null, "oxsomething");
if(\$context["foo"]) {
echo "Lorem Ipsum";
}
unset(\$context["foo"]);
EOF
];
Expand Down

0 comments on commit 5878039

Please sign in to comment.