Skip to content

Commit

Permalink
Merge branch '3.x' into 4.x
Browse files Browse the repository at this point in the history
* 3.x:
  Add a recipe about how to mark a node as safe
  Mark ConstantExpression as @Final
  • Loading branch information
fabpot committed Aug 7, 2024
2 parents a588276 + 15854ca commit a159617
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
11 changes: 11 additions & 0 deletions doc/recipes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -483,4 +483,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
3 changes: 3 additions & 0 deletions src/Node/Expression/ConstantExpression.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@

use Twig\Compiler;

/**
* @final
*/
class ConstantExpression extends AbstractExpression
{
public function __construct($value, int $lineno)
Expand Down

0 comments on commit a159617

Please sign in to comment.