From 4f97f295ca75d740a61f5a3a2078f333c54f685e Mon Sep 17 00:00:00 2001 From: David Grudl Date: Tue, 1 Jun 2021 22:42:29 +0200 Subject: [PATCH] UIMacros: supports {control|noescape} --- src/Bridges/ApplicationLatte/UIMacros.php | 6 ++++-- tests/Bridges.Latte/UIMacros.control.3.phpt | 5 +++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Bridges/ApplicationLatte/UIMacros.php b/src/Bridges/ApplicationLatte/UIMacros.php index dbdbe7960..139b77df0 100644 --- a/src/Bridges/ApplicationLatte/UIMacros.php +++ b/src/Bridges/ApplicationLatte/UIMacros.php @@ -81,11 +81,13 @@ public function finalize() */ public function macroControl(MacroNode $node, PhpWriter $writer) { + if ($node->context !== [Latte\Compiler::CONTENT_HTML, Latte\Compiler::CONTEXT_HTML_TEXT]) { + $tmp = Latte\Helpers::removeFilter($node->modifiers, 'noescape') ? '' : '|escape'; + } if ($node->modifiers) { trigger_error('Modifiers are deprecated in ' . $node->getNotation(), E_USER_DEPRECATED); - } elseif ($node->context !== [Latte\Compiler::CONTENT_HTML, Latte\Compiler::CONTEXT_HTML_TEXT]) { - $node->modifiers .= '|escape'; } + $node->modifiers .= $tmp ?? ''; $words = $node->tokenizer->fetchWords(); if (!$words) { diff --git a/tests/Bridges.Latte/UIMacros.control.3.phpt b/tests/Bridges.Latte/UIMacros.control.3.phpt index ac290052f..5785b2eeb 100644 --- a/tests/Bridges.Latte/UIMacros.control.3.phpt +++ b/tests/Bridges.Latte/UIMacros.control.3.phpt @@ -33,6 +33,11 @@ Assert::exception(function () use ($latte) { $latte->renderToString('
&', + $latte->renderToString('
', $latte->renderToString('
')