This PR was merged into the 1.x branch.
Discussion
----------
Fix a PHP fatal error when calling a macro, imported in the template, in another macro
The current code iterates over all imported functions (traversing all the scopes). So, the macro was found at compilation time, but didn't work at runtime, leading to a PHP fatal error. Now, you get a proper exception at compilation time.
Commits
-------
ba9b9681 fixed a PHP fatal error when calling a macro, imported in the template, in another macro
* 2.x:
tweaked error messages
fixed wrong error message on "import" and "from"
bumped version to 2.10.1-DEV
prepared the 2.10.0 release
bumped version to 1.41.1-DEV
prepared the 1.41.0 release
Correct Twig_SimpleFilter/Twig_SimpleFunction/Twig_SimpleTest deprecation doc (Revert: moved to namespaced classes by default)
fixed PHP 7.4 support
This PR was merged into the 1.x branch.
Discussion
----------
Fix wrong error message on "import" and "from"
Commits
-------
118462c1 fixed wrong error message on "import" and "from"
* 1.x:
Correct Twig_SimpleFilter/Twig_SimpleFunction/Twig_SimpleTest deprecation doc (Revert: moved to namespaced classes by default)
fixed PHP 7.4 support
This PR was merged into the 1.x branch.
Discussion
----------
Correct Twig_SimpleFilter, Twig_SimpleFunction, Twig_SimpleTest deprecation doc
Reverts https://github.com/twigphp/Twig/commit/3632a46e82fbb391b0fc72674bd8946e0b7c5bf7 for deprecated.rst
Commits
-------
65047482 Correct Twig_SimpleFilter/Twig_SimpleFunction/Twig_SimpleTest deprecation doc (Revert: moved to namespaced classes by default)
This PR was merged into the 3.x branch.
Discussion
----------
Remove the "if" condition support on the "for" tag
Commits
-------
dca3f74e removed the "if" condition support on the "for" tag
This PR was squashed before being merged into the 1.x branch (closes#3004).
Discussion
----------
Fix support for PHP 7.4
Commits
-------
f958bd1e fixed deprecation under PHP 7.4
1fb0f970 fixed PHP 7.4 support
7be8e944 added PHP 7.4 in Travis config
This PR was merged into the 1.x branch.
Discussion
----------
Fix support for IteratorAggregate in the filter filter
Commits
-------
084be27d fixed support for IteratorAggregate in the filter filter
This PR was merged into the 2.x branch.
Discussion
----------
Deprecate "if" conditions on "for" tags
Commits
-------
5d1d90ba deprecated "if" conditions on "for" tags
* 2.x:
fixed CS
added the key to the map and filter filters
added support for iterators
removed fn in front of arrow functions
changed arrow syntax
added "filter", "map", and "reduce" filters
simplified code
fixed CS
bumped version to 2.10
bumped version to 1.41
fixed partial output leak when a PHP fatal error occurs
fixed markup in docs
* 1.x:
added the key to the map and filter filters
added support for iterators
removed fn in front of arrow functions
changed arrow syntax
added "filter", "map", and "reduce" filters
simplified code
fixed CS
fixed partial output leak when a PHP fatal error occurs
This PR was squashed before being merged into the 1.x branch (closes#2996).
Discussion
----------
Add "filter", "map", and "reduce" filters
This PR adds support for 3 new filters: `filter`, `map`, and `reduce`. They take an arrow function as an argument (a PHP closure).
I have restricted the usage of arrow functions as much as possible as it makes no sense to support them everywhere. So, for now, they are only accepted as arguments to filters (using them as arguments to function is not supported but could be easily added if we have a use case).
The syntax is the following: `(x) => x + 3` where `(x)` is the list of arguments, `=>` starts the body, and the body is any Twig expression. Within the arrow function, the context is also available: `(x) => x + offset` works if `offset` is defined in the current context.
~~These new filters will allow us to deprecate the `if` support on the `for` tag, which does not work well with the `loop` variable:~~
```twig
{% set sizes = {xs: 34, s: 36, m: 38, l: 40, xl: 42} %}
{# before #}
{% for name, size in sizes if size < 38 %}
{{ name }} = {{ size }}
{% loop.last ? 'LAST' %} {# <--- works with this PR #}
{% endfor %}
{# after #}
{% for name, size in sizes|filter(size => size < 38) %}
{{ name }} = {{ size }}
{{ loop.last ? 'LAST' }}
{% endfor %}
```
This closes#2785
Commits
-------
5c15f897 added the key to the map and filter filters
13274bbf added support for iterators
175041e0 removed fn in front of arrow functions
dc277635 changed arrow syntax
b30bce11 added "filter", "map", and "reduce" filters
This PR was merged into the 1.x branch.
Discussion
----------
Fix partial output leak when a PHP fatal error occurs
closes#1962 (thank you @fluff for the "trick")
Commits
-------
6196fe5b fixed partial output leak when a PHP fatal error occurs