mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-15 20:06:31 +00:00
deprecated using the spaceless tag at the root level of a child template (noop anyway)
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
* 2.5.0 (2018-XX-XX)
|
* 2.5.0 (2018-XX-XX)
|
||||||
|
|
||||||
|
* deprecated using the spaceless tag at the root level of a child template (noop anyway)
|
||||||
* deprecated the possibility to define a block in a non-capturing block in a child template
|
* deprecated the possibility to define a block in a non-capturing block in a child template
|
||||||
* added the Symfony ctype polyfill as a dependency
|
* added the Symfony ctype polyfill as a dependency
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,13 @@ Inheritance
|
|||||||
``Twig_Error_Syntax`` exception. It does not work anyway, so most projects
|
``Twig_Error_Syntax`` exception. It does not work anyway, so most projects
|
||||||
won't need to do anything to upgrade.
|
won't need to do anything to upgrade.
|
||||||
|
|
||||||
|
Tags
|
||||||
|
----
|
||||||
|
|
||||||
|
* Using the ``spaceless`` tag at the root level of a child template is
|
||||||
|
deprecated in Twig 2.5.0. This does not work as one would expect it to work
|
||||||
|
anyway. In Twig 3.0, it will throw a ``Twig_Error_Syntax`` exception.
|
||||||
|
|
||||||
Final Classes
|
Final Classes
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
*
|
*
|
||||||
* @author Fabien Potencier <fabien@symfony.com>
|
* @author Fabien Potencier <fabien@symfony.com>
|
||||||
*/
|
*/
|
||||||
class Twig_Node_Spaceless extends Twig_Node
|
class Twig_Node_Spaceless extends Twig_Node implements Twig_NodeOutputInterface
|
||||||
{
|
{
|
||||||
public function __construct(Twig_Node $body, $lineno, $tag = 'spaceless')
|
public function __construct(Twig_Node $body, $lineno, $tag = 'spaceless')
|
||||||
{
|
{
|
||||||
|
|||||||
+9
-2
@@ -319,7 +319,8 @@ class Twig_Parser
|
|||||||
if (
|
if (
|
||||||
($node instanceof Twig_Node_Text && !ctype_space($node->getAttribute('data')))
|
($node instanceof Twig_Node_Text && !ctype_space($node->getAttribute('data')))
|
||||||
||
|
||
|
||||||
(!$node instanceof Twig_Node_Text && !$node instanceof Twig_Node_BlockReference && $node instanceof Twig_NodeOutputInterface)
|
// the "&& !$node instanceof Twig_Node_Spaceless" part of the condition must be removed in 3.0
|
||||||
|
(!$node instanceof Twig_Node_Text && !$node instanceof Twig_Node_BlockReference && ($node instanceof Twig_NodeOutputInterface && !$node instanceof Twig_Node_Spaceless))
|
||||||
) {
|
) {
|
||||||
if (false !== strpos((string) $node, chr(0xEF).chr(0xBB).chr(0xBF))) {
|
if (false !== strpos((string) $node, chr(0xEF).chr(0xBB).chr(0xBF))) {
|
||||||
throw new Twig_Error_Syntax('A template that extends another one cannot start with a byte order mark (BOM); it must be removed.', $node->getTemplateLine(), $this->stream->getSourceContext());
|
throw new Twig_Error_Syntax('A template that extends another one cannot start with a byte order mark (BOM); it must be removed.', $node->getTemplateLine(), $this->stream->getSourceContext());
|
||||||
@@ -334,6 +335,11 @@ class Twig_Parser
|
|||||||
return $node;
|
return $node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// to be removed completely in Twig 3.0
|
||||||
|
if (!$nested && $node instanceof Twig_Node_Spaceless) {
|
||||||
|
@trigger_error(sprintf('Using the spaceless tag at the root level of a child template in "%s" at line %d is deprecated since version 2.5.0 and will become a syntax error in 3.0.', $this->stream->getSourceContext()->getName(), $node->getTemplateLine()), E_USER_DEPRECATED);
|
||||||
|
}
|
||||||
|
|
||||||
// "block" tags that are not captured (see above) are only used for defining
|
// "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
|
// 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.
|
// expected as the definition is not part of the default template code flow.
|
||||||
@@ -343,7 +349,8 @@ class Twig_Parser
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($node instanceof Twig_NodeOutputInterface) {
|
// the "&& !$node instanceof Twig_Node_Spaceless" part of the condition must be removed in 3.0
|
||||||
|
if ($node instanceof Twig_NodeOutputInterface && !$node instanceof Twig_Node_Spaceless) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
--TEST--
|
||||||
|
"spaceless" tag in the root level of a child template
|
||||||
|
--DEPRECATION--
|
||||||
|
Using the spaceless tag at the root level of a child template in "index.twig" at line 3 is deprecated since version 2.5.0 and will become a syntax error in 3.0.
|
||||||
|
Nesting a block definition under a non-capturing node in "index.twig" at line 4 is deprecated since version 2.5.0 and will become a syntax error in 3.0.
|
||||||
|
--TEMPLATE--
|
||||||
|
{% extends "layout.twig" %}
|
||||||
|
{% spaceless %}
|
||||||
|
{% block content %}
|
||||||
|
<h1>
|
||||||
|
<b>Title</b>
|
||||||
|
</h1>
|
||||||
|
{% endblock %}
|
||||||
|
{% endspaceless %}
|
||||||
|
--TEMPLATE(layout.twig)--
|
||||||
|
{% block content %}FOO{% endblock %}
|
||||||
|
--DATA--
|
||||||
|
return array()
|
||||||
|
--EXPECT--
|
||||||
|
<h1>
|
||||||
|
<b>Title</b>
|
||||||
|
</h1>
|
||||||
Reference in New Issue
Block a user