removed block definition nested in non-capturing nodes

This commit is contained in:
Fabien Potencier
2019-04-23 18:24:31 +02:00
parent 2fa26d6f4a
commit 02767df5c0
2 changed files with 4 additions and 9 deletions
+2 -5
View File
@@ -352,11 +352,8 @@ class Parser
// "block" tags that are not captured (see above) are only used for defining
// the content of the block. In such a case, nesting it does not work as
// expected as the definition is not part of the default template code flow.
if ($nested && ($node instanceof BlockReferenceNode || $node instanceof \Twig_Node_BlockReference)) {
//throw new SyntaxError('A block definition cannot be nested under non-capturing nodes.', $node->getTemplateLine(), $this->stream->getSourceContext());
@trigger_error(sprintf('Nesting a block definition under a non-capturing node in "%s" at line %d is deprecated since Twig 2.5.0 and will become a syntax error in 3.0.', $this->stream->getSourceContext()->getName(), $node->getTemplateLine()), E_USER_DEPRECATED);
return;
if ($nested && $node instanceof BlockReferenceNode) {
throw new SyntaxError('A block definition cannot be nested under non-capturing nodes.', $node->getTemplateLine(), $this->stream->getSourceContext());
}
if ($node instanceof NodeOutputInterface) {
@@ -1,7 +1,5 @@
--TEST--
conditional "block" tag with "extends" tag
--DEPRECATION--
Nesting a block definition under a non-capturing node in "index.twig" at line 5 is deprecated since Twig 2.5.0 and will become a syntax error in 3.0.
--TEMPLATE--
{% extends "layout.twig" %}
@@ -12,5 +10,5 @@ Nesting a block definition under a non-capturing node in "index.twig" at line 5
{% block content %}{% endblock %}
--DATA--
return array()
--EXPECT--
FOO
--EXCEPTION--
Twig\Error\SyntaxError: A block definition cannot be nested under non-capturing nodes in "index.twig" at line 5.