deprecated the filter tag

This commit is contained in:
Fabien Potencier
2019-04-24 19:44:11 +02:00
parent 8f8c0c3d10
commit 776e32bc7a
12 changed files with 29 additions and 6 deletions
+1
View File
@@ -1,5 +1,6 @@
* 2.9.0 (2019-XX-XX) * 2.9.0 (2019-XX-XX)
* deprecated the "filter" tag (use the "apply" tag instead)
* added template line number to twig_get_attribute() * added template line number to twig_get_attribute()
* 2.8.1 (2019-04-16) * 2.8.1 (2019-04-16)
+4 -1
View File
@@ -29,13 +29,16 @@ Tags
---- ----
* The ``spaceless`` tag is deprecated in Twig 2.7. Use the ``spaceless`` filter * The ``spaceless`` tag is deprecated in Twig 2.7. Use the ``spaceless`` filter
instead or ``{% filter spaceless %}`` (the ``Twig\Node\SpacelessNode`` and instead or ``{% apply spaceless %}`` (the ``Twig\Node\SpacelessNode`` and
``Twig\TokenParser\SpacelessTokenParser`` classes are also deprecated). ``Twig\TokenParser\SpacelessTokenParser`` classes are also deprecated).
* Using the ``spaceless`` tag at the root level of a child template is * 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 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\SyntaxError`` exception. anyway. In Twig 3.0, it will throw a ``Twig\Error\SyntaxError`` exception.
* The ``filter`` tag is deprecated in Twig 2.9. Use the ``apply`` tag instead
(the ``Twig\TokenParser\FilterTokenParser`` classes is also deprecated).
Final Classes Final Classes
------------- -------------
+4
View File
@@ -23,11 +23,15 @@ use Twig\Token;
* {% filter upper %} * {% filter upper %}
* This text becomes uppercase * This text becomes uppercase
* {% endfilter %} * {% endfilter %}
*
* @deprecated since Twig 2.9, to be removed in 3.0 (use the "apply" tag instead)
*/ */
final class FilterTokenParser extends AbstractTokenParser final class FilterTokenParser extends AbstractTokenParser
{ {
public function parse(Token $token) public function parse(Token $token)
{ {
@trigger_error('The "filter" tag is deprecated since Twig 2.9, use the "apply" tag instead.', E_USER_DEPRECATED);
$name = $this->parser->getVarName(); $name = $this->parser->getVarName();
$ref = new BlockReferenceExpression(new ConstantExpression($name, $token->getLine()), null, $token->getLine(), $this->getTag()); $ref = new BlockReferenceExpression(new ConstantExpression($name, $token->getLine()), null, $token->getLine(), $this->getTag());
@@ -4,7 +4,7 @@ macro with a filter
{% import _self as test %} {% import _self as test %}
{% macro test() %} {% macro test() %}
{% filter escape %}foo<br />{% endfilter %} {% apply escape %}foo<br />{% endapply %}
{% endmacro %} {% endmacro %}
{{ test.test() }} {{ test.test() }}
@@ -3,14 +3,14 @@ Block names are unique per template
--TEMPLATE-- --TEMPLATE--
{% extends 'layout' %} {% extends 'layout' %}
{% block content -%} {% block content -%}
{% filter title -%} {% apply title -%}
second second
{% endfilter %} {% endapply %}
{% endblock %} {% endblock %}
--TEMPLATE(layout)-- --TEMPLATE(layout)--
{% filter title -%} {% apply title -%}
first first
{% endfilter %} {% endapply %}
{% block content %}{% endblock %} {% block content %}{% endblock %}
--DATA-- --DATA--
return [] return []
@@ -1,5 +1,7 @@
--TEST-- --TEST--
"filter" tag applies a filter on its children "filter" tag applies a filter on its children
--DEPRECATION--
The "filter" tag is deprecated since Twig 2.9, use the "apply" tag instead.
--TEMPLATE-- --TEMPLATE--
{% filter upper %} {% filter upper %}
Some text with a {{ var }} Some text with a {{ var }}
@@ -1,5 +1,7 @@
--TEST-- --TEST--
"filter" tag applies a filter on its children "filter" tag applies a filter on its children
--DEPRECATION--
The "filter" tag is deprecated since Twig 2.9, use the "apply" tag instead.
--TEMPLATE-- --TEMPLATE--
{% filter json_encode|raw %}test{% endfilter %} {% filter json_encode|raw %}test{% endfilter %}
--DATA-- --DATA--
@@ -1,5 +1,7 @@
--TEST-- --TEST--
"filter" tags accept multiple chained filters "filter" tags accept multiple chained filters
--DEPRECATION--
The "filter" tag is deprecated since Twig 2.9, use the "apply" tag instead.
--TEMPLATE-- --TEMPLATE--
{% filter lower|title %} {% filter lower|title %}
{{ var }} {{ var }}
@@ -1,5 +1,8 @@
--TEST-- --TEST--
"filter" tags can be nested at will "filter" tags can be nested at will
--DEPRECATION--
The "filter" tag is deprecated since Twig 2.9, use the "apply" tag instead.
The "filter" tag is deprecated since Twig 2.9, use the "apply" tag instead.
--TEMPLATE-- --TEMPLATE--
{% filter lower|title %} {% filter lower|title %}
{{ var }} {{ var }}
@@ -1,5 +1,7 @@
--TEST-- --TEST--
"scope" tag creates a new scope "scope" tag creates a new scope
--DEPRECATION--
The "filter" tag is deprecated since Twig 2.9, use the "apply" tag instead.
--TEMPLATE-- --TEMPLATE--
{% filter spaceless %} {% filter spaceless %}
{% set item = 'foo' %} {% set item = 'foo' %}
@@ -1,5 +1,7 @@
--TEST-- --TEST--
"filter" tag applies the filter on "for" tags "filter" tag applies the filter on "for" tags
--DEPRECATION--
The "filter" tag is deprecated since Twig 2.9, use the "apply" tag instead.
--TEMPLATE-- --TEMPLATE--
{% filter upper %} {% filter upper %}
{% for item in items %} {% for item in items %}
@@ -1,5 +1,7 @@
--TEST-- --TEST--
"filter" tag applies the filter on "if" tags "filter" tag applies the filter on "if" tags
--DEPRECATION--
The "filter" tag is deprecated since Twig 2.9, use the "apply" tag instead.
--TEMPLATE-- --TEMPLATE--
{% filter upper %} {% filter upper %}
{% if items %} {% if items %}