Commit Graph

4630 Commits

Author SHA1 Message Date
Fabien Potencier dca3f74e49 removed the "if" condition support on the "for" tag 2019-05-14 09:17:47 +02:00
Fabien Potencier 7c16b12326 fixed CS 2019-05-14 09:17:34 +02:00
Fabien Potencier 69d4060de8 Merge branch '2.x' into 3.x
* 2.x:
  fixed deprecation under PHP 7.4
  fixed PHP 7.4 support
  added PHP 7.4 in Travis config
2019-05-14 08:47:41 +02:00
Fabien Potencier 2efd1c5515 Merge branch '1.x' into 2.x
* 1.x:
  fixed deprecation under PHP 7.4
  fixed PHP 7.4 support
  added PHP 7.4 in Travis config
2019-05-14 08:46:40 +02:00
Fabien Potencier 611a29c48c bug #3004 Fix support for PHP 7.4 (fabpot)
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
2019-05-14 08:45:39 +02:00
Fabien Potencier f958bd1e86 fixed deprecation under PHP 7.4 2019-05-14 08:40:21 +02:00
Fabien Potencier 1fb0f9701d fixed PHP 7.4 support 2019-05-14 08:18:04 +02:00
Fabien Potencier 7be8e9443d added PHP 7.4 in Travis config 2019-05-14 07:20:38 +02:00
Fabien Potencier edbcaa3ca5 Merge branch '2.x' into 3.x
* 2.x:
  fixed support for IteratorAggregate in the filter filter
2019-05-10 08:47:14 +02:00
Fabien Potencier ed3cbebe47 Merge branch '1.x' into 2.x
* 1.x:
  fixed support for IteratorAggregate in the filter filter
2019-05-10 08:47:07 +02:00
Fabien Potencier 2e1e9528ce bug #2999 Fix support for IteratorAggregate in the filter filter (fabpot)
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
2019-05-10 08:46:52 +02:00
Fabien Potencier 084be27d77 fixed support for IteratorAggregate in the filter filter 2019-05-10 08:33:19 +02:00
Fabien Potencier f31fe6add4 Merge branch '2.x' into 3.x
* 2.x:
  deprecated "if" conditions on "for" tags
  updated CHANGELOG
  added a test
2019-05-09 17:36:40 +02:00
Fabien Potencier 47085e8d95 feature #2998 Deprecate "if" conditions on "for" tags (fabpot)
This PR was merged into the 2.x branch.

Discussion
----------

Deprecate "if" conditions on "for" tags

Commits
-------

5d1d90ba deprecated "if" conditions on "for" tags
2019-05-09 17:35:47 +02:00
Fabien Potencier 5d1d90ba53 deprecated "if" conditions on "for" tags 2019-05-09 15:20:13 +02:00
Fabien Potencier d891cda943 updated CHANGELOG 2019-05-09 14:16:14 +02:00
Fabien Potencier ceac00eec6 Merge branch '1.x' into 2.x
* 1.x:
  added a test
2019-05-09 13:58:01 +02:00
Fabien Potencier 990eec8740 added a test 2019-05-09 13:52:01 +02:00
Fabien Potencier 3d1b9a11d8 Merge branch '2.x' into 3.x
* 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
2019-05-09 13:29:19 +02:00
Fabien Potencier 00966f434f fixed CS 2019-05-09 13:27:48 +02:00
Fabien Potencier 5c484ce7eb Merge branch '1.x' into 2.x
* 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
2019-05-09 13:25:49 +02:00
Fabien Potencier 3d95ffe906 feature #2996 Add "filter", "map", and "reduce" filters (fabpot)
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
2019-05-09 13:18:48 +02:00
Fabien Potencier 5c15f897c7 added the key to the map and filter filters 2019-05-03 19:04:11 +02:00
Fabien Potencier 13274bbf97 added support for iterators 2019-05-03 18:15:56 +02:00
Fabien Potencier 175041e01b removed fn in front of arrow functions 2019-05-03 18:12:19 +02:00
Fabien Potencier dc2776359c changed arrow syntax 2019-05-03 17:09:12 +02:00
Fabien Potencier b30bce1139 added "filter", "map", and "reduce" filters 2019-05-03 17:09:12 +02:00
Fabien Potencier 5d37a3260a bug #2995 Fix partial output leak when a PHP fatal error occurs (fabpot)
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
2019-05-03 17:08:09 +02:00
Fabien Potencier ababe1a430 simplified code 2019-05-03 15:44:36 +02:00
Fabien Potencier df9c40ad53 fixed CS 2019-05-03 15:28:57 +02:00
Fabien Potencier cf733f4f96 bumped version to 2.10 2019-05-03 10:33:50 +02:00
Fabien Potencier 1d555e1d10 Merge branch '1.x' into 2.x
* 1.x:
  bumped version to 1.41
2019-05-03 10:33:25 +02:00
Fabien Potencier a795acd1da bumped version to 1.41 2019-05-03 10:32:27 +02:00
Fabien Potencier 6196fe5b40 fixed partial output leak when a PHP fatal error occurs 2019-05-03 08:42:27 +02:00
Fabien Potencier 79c9b05856 Merge branch '1.x' into 2.x
* 1.x:
  fixed markup in docs
2019-05-03 05:45:53 +02:00
Fabien Potencier d3acd0bede fixed markup in docs 2019-05-03 05:45:17 +02:00
Fabien Potencier 8d82f62418 disabled Drupal tests on 3.x 2019-05-01 16:00:56 +02:00
Fabien Potencier 6139edc1e5 Merge branch '2.x' into 3.x
* 2.x:
  required 8.7 for Drupal tests
  fixed Drupal script
  added Drupal in the CI process
2019-05-01 15:49:37 +02:00
Fabien Potencier d997512294 required 8.7 for Drupal tests 2019-05-01 15:44:34 +02:00
Fabien Potencier 3c6c0fec46 Merge branch '1.x' into 2.x
* 1.x:
  fixed Drupal script
2019-05-01 10:58:16 +02:00
Fabien Potencier ed083c8a93 fixed Drupal script 2019-05-01 10:58:08 +02:00
Fabien Potencier c451535c46 Merge branch '1.x' into 2.x
* 1.x:
  added Drupal in the CI process
2019-05-01 10:42:11 +02:00
Fabien Potencier 364f4cb024 feature #2993 Add tests to avoid regressions (via Drupal) (fabpot)
This PR was merged into the 1.x branch.

Discussion
----------

Add tests to avoid regressions (via Drupal)

Commits
-------

9c313e3c added Drupal in the CI process
2019-05-01 10:41:10 +02:00
Fabien Potencier 9c313e3c2d added Drupal in the CI process 2019-05-01 10:06:25 +02:00
Fabien Potencier 23a5d57cfa Merge branch '2.x' into 3.x
* 2.x:
  removed wrong link in docs
  fixed doc markup
  optimized context access on PHP 7.4
2019-04-30 15:02:09 +02:00
Fabien Potencier 804cf65ec0 Merge branch '1.x' into 2.x
* 1.x:
  optimized context access on PHP 7.4
2019-04-30 15:01:59 +02:00
Fabien Potencier 7395b7ab95 feature #2985 Optimize context access on PHP 7.4 (fabpot)
This PR was merged into the 1.x branch.

Discussion
----------

Optimize context access on PHP 7.4

Commits
-------

5b5f5659 optimized context access on PHP 7.4
2019-04-30 14:47:37 +02:00
Fabien Potencier d03684c9f2 Merge branch '1.x' into 2.x
* 1.x:
  removed wrong link in docs
  fixed doc markup
2019-04-30 14:27:24 +02:00
Fabien Potencier bd7ca26497 removed wrong link in docs 2019-04-30 14:26:21 +02:00
Fabien Potencier 61eb901f16 fixed doc markup 2019-04-30 14:23:18 +02:00