Add a recipe about how to mark a node as safe

This commit is contained in:
Fabien Potencier
2024-08-07 19:06:26 +02:00
parent 693693ba3a
commit 230e31d384
2 changed files with 12 additions and 0 deletions
+1
View File
@@ -1,5 +1,6 @@
# 3.11.0 (2024-XX-XX)
* Mark `ConstantExpression` as being `@final`
* Add the `find` filter
* Fix optimizer mode validation in `OptimizerNodeVisitor`
* Add the possibility to yield from a generator in `PrintNode`
+11
View File
@@ -528,4 +528,15 @@ include in your templates:
'tag_variable' => ['{[', ']}'],
]));
Marking a Node as being safe
----------------------------
When using the escaper extension, you might want to mark some nodes as being
safe to avoid any escaping. You can do so by wrapping your expression with a
``RawFilter`` node::
use Twig\Node\Expression\Filter\RawFilter;
$safeExpr = new RawFilter(new YourSafeNode());
.. _callback: https://www.php.net/manual/en/function.is-callable.php