diff --git a/src/Twig/Node/CSPNode.php b/src/Twig/Node/CSPNode.php index 8d81b16..840f9d3 100644 --- a/src/Twig/Node/CSPNode.php +++ b/src/Twig/Node/CSPNode.php @@ -76,6 +76,11 @@ public function compile(Compiler $compiler): void } else { throw new \InvalidArgumentException(sprintf('Unable to compile for directive "%s"', $this->directive)); } - $compiler->write("echo \$content;\n"); + + if (class_exists(CaptureNode::class)) { + $compiler->write("yield \$content;\n"); + } else { + $compiler->write("echo \$content;\n"); + } } }