mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-17 04:46:49 +00:00
removed block definition nested in non-capturing nodes
This commit is contained in:
+2
-5
@@ -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) {
|
||||
|
||||
+2
-4
@@ -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.
|
||||
Reference in New Issue
Block a user