Skip to content

Commit

Permalink
Do not pass "$tag" parameter to Twig_Node constructor
Browse files Browse the repository at this point in the history
> Since twig/twig 3.12: The "tag" constructor argument of the "NotFloran\MjmlBundle\Twig\Node"
class is deprecated and ignored (check which
TokenParser class set it to "mjml"), the tag is now
automatically set by the Parser when needed.
  • Loading branch information
pan93412 committed Dec 11, 2024
1 parent 651865d commit 875378c
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/Twig/Node.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,20 @@ class Node extends Twig_Node
*/
public function __construct(Twig_Node $value, $line, $tag = null)
{
$twigGreaterThan312 = version_compare(\Twig\Environment::VERSION, '3.12', '>=');

if (class_exists(CaptureNode::class)) {
$value = new CaptureNode($value, $line, $tag);
$value = $twigGreaterThan312
? new CaptureNode($value, $line)
: new CaptureNode($value, $line, $tag);
$value->setAttribute('raw', true);
}

parent::__construct(['value' => $value], ['name' => $tag], $line, $tag);
if ($twigGreaterThan312) {
parent::__construct(['value' => $value], ['name' => $tag], $line);
} else {
parent::__construct(['value' => $value], ['name' => $tag], $line, $tag);
}
}

/**
Expand Down

0 comments on commit 875378c

Please sign in to comment.