mirror of
https://github.com/twigphp/Twig.git
synced 2026-08-30 12:06:56 +00:00
deprecated "if" conditions on "for" tags
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
* 2.10.0 (2019-XX-XX)
|
||||
|
||||
* deprecated "if" conditions on "for" tags
|
||||
* added "filter", "map", and "reduce" filters (and support for arrow functions)
|
||||
* fixed partial output leak when a PHP fatal error occurs
|
||||
* optimized context access on PHP 7.4
|
||||
|
||||
@@ -39,6 +39,10 @@ Tags
|
||||
* The ``filter`` tag is deprecated in Twig 2.9. Use the ``apply`` tag instead
|
||||
(the ``Twig\TokenParser\FilterTokenParser`` classes is also deprecated).
|
||||
|
||||
* Adding an ``if`` condition on a ``for`` tag is deprecated in Twig 2.10. Use a
|
||||
``filter`` filter or an "if" condition inside the "for" body instead (if your condition
|
||||
depends on a variable updated inside the loop)
|
||||
|
||||
Final Classes
|
||||
-------------
|
||||
|
||||
|
||||
@@ -43,6 +43,8 @@ final class ForTokenParser extends AbstractTokenParser
|
||||
|
||||
$ifexpr = null;
|
||||
if ($stream->nextIf(/* Token::NAME_TYPE */ 5, 'if')) {
|
||||
@trigger_error(sprintf('Using an "if" condition on "for" tag is deprecated since Twig 2.10.0, use a "filter" filter or an "if" condition inside the "for" body instead (if your condition depends on a variable updated inside the loop).', __CLASS__), E_USER_DEPRECATED);
|
||||
|
||||
$ifexpr = $this->parser->getExpressionParser()->parseExpression();
|
||||
}
|
||||
|
||||
|
||||
+2
@@ -1,5 +1,7 @@
|
||||
--TEST--
|
||||
"for" tag takes a condition
|
||||
--DEPRECATION--
|
||||
Using an "if" condition on "for" tag is deprecated since Twig 2.10.0, use a "filter" filter or an "if" condition inside the "for" body instead (if your condition depends on a variable updated inside the loop).
|
||||
--TEMPLATE--
|
||||
{% for i in 1..5 if i is odd -%}
|
||||
{{ loop.index }}.{{ i }}{{ foo.bar }}
|
||||
Reference in New Issue
Block a user