From aaf493e997da2be98bed54635be4c0d6e08609d1 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Wed, 10 Jan 2024 14:18:54 +0100 Subject: [PATCH] FilterNode::printContentAware() moved to ModifierNode [WIP] --- src/Latte/Compiler/Nodes/Php/FilterNode.php | 15 --------------- src/Latte/Compiler/Nodes/Php/ModifierNode.php | 13 +++++++++++-- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/src/Latte/Compiler/Nodes/Php/FilterNode.php b/src/Latte/Compiler/Nodes/Php/FilterNode.php index cd038368e..57aa3336e 100644 --- a/src/Latte/Compiler/Nodes/Php/FilterNode.php +++ b/src/Latte/Compiler/Nodes/Php/FilterNode.php @@ -9,7 +9,6 @@ namespace Latte\Compiler\Nodes\Php; -use Latte\CompileException; use Latte\Compiler\Node; use Latte\Compiler\Position; use Latte\Compiler\PrintContext; @@ -34,20 +33,6 @@ public function print(PrintContext $context): string } - public function printContentAware(PrintContext $context, string $expr): string - { - if ($this->nullsafe) { - throw new CompileException('Nullsafe pipe is not allowed here', $this->position); - } - return '$this->filters->filterContent(' - . $context->encodeString($this->name->name) - . ', $ʟ_fi, ' - . $expr - . ($this->args ? ', ' . $context->implode($this->args) : '') - . ')'; - } - - public function &getIterator(): \Generator { yield $this->name; diff --git a/src/Latte/Compiler/Nodes/Php/ModifierNode.php b/src/Latte/Compiler/Nodes/Php/ModifierNode.php index 7c9394ebb..74ff3f68c 100644 --- a/src/Latte/Compiler/Nodes/Php/ModifierNode.php +++ b/src/Latte/Compiler/Nodes/Php/ModifierNode.php @@ -9,6 +9,7 @@ namespace Latte\Compiler\Nodes\Php; +use Latte\CompileException; use Latte\Compiler\Node; use Latte\Compiler\Nodes\Php\Expression\FiltersCallNode; use Latte\Compiler\Position; @@ -85,9 +86,17 @@ public function printContentAware(PrintContext $context, string $expr): string $name = $filter->name->name; if ($name === 'noescape') { $noescape = true; - } else { - $expr = $filter->printContentAware($context, $expr); + continue; + } elseif ($filter->nullsafe) { + throw new CompileException('Nullsafe pipe is not allowed here', $filter->position); } + + $expr = '$this->filters->filterContent(' + . $context->encodeString($filter->name->name) + . ', $ʟ_fi, ' + . $expr + . ($filter->args ? ', ' . $context->implode($filter->args) : '') + . ')'; } if ($this->escape && empty($noescape)) {