Commit Graph

4583 Commits

Author SHA1 Message Date
Fabien Potencier 4e1c3b8a7c Merge branch '1.x' into 2.x
* 1.x:
  added some tests
2019-05-16 21:02:31 +02:00
Fabien Potencier 6b341104ec added some tests 2019-05-16 21:02:14 +02:00
Fabien Potencier 73326f0ddc Merge branch '1.x' into 2.x
* 1.x:
  fixed a regression
2019-05-16 20:18:06 +02:00
Fabien Potencier bd1f9eb39b bug #3011 Fix a regression (fabpot)
This PR was merged into the 1.x branch.

Discussion
----------

Fix a regression

Commits
-------

3c7602b9 fixed a regression
2019-05-16 20:17:10 +02:00
Fabien Potencier 3c7602b9da fixed a regression 2019-05-16 19:44:44 +02:00
Fabien Potencier e671f267ce Merge branch '1.x' into 2.x
* 1.x:
  made code more readable
2019-05-16 16:31:36 +02:00
Fabien Potencier 06670f3630 made code more readable 2019-05-16 16:30:26 +02:00
Fabien Potencier ad1d08a431 Merge branch '1.x' into 2.x
* 1.x:
  tweaked the error message when using extends in a block/macro
2019-05-16 16:16:50 +02:00
Fabien Potencier 0968176a05 bug #3010 Tweak the error message when using extends in a block/macro (fabpot)
This PR was merged into the 1.x branch.

Discussion
----------

Tweak the error message when using extends in a block/macro

Commits
-------

70c1b3a2 tweaked the error message when using extends in a block/macro
2019-05-16 16:16:26 +02:00
Fabien Potencier 70c1b3a2c2 tweaked the error message when using extends in a block/macro 2019-05-16 16:07:04 +02:00
Fabien Potencier b0f29468f0 simplified code 2019-05-16 14:16:39 +02:00
Fabien Potencier 10d1145ef6 Merge branch '1.x' into 2.x
* 1.x:
  fixed a PHP fatal error when calling a macro, imported in the template, in another macro
2019-05-16 14:16:01 +02:00
Fabien Potencier 6315ea4786 bug #3009 Fix a PHP fatal error when calling a macro, imported in the template, in another macro (fabpot)
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
2019-05-16 14:15:37 +02:00
Fabien Potencier ba9b9681ca fixed a PHP fatal error when calling a macro, imported in the template, in another macro 2019-05-16 14:09:44 +02:00
Fabien Potencier b5ad4c36cf Merge branch '1.x' into 2.x
* 1.x:
  tweaked error messages
  fixed wrong error message on "import" and "from"
  bumped version to 1.41.1-DEV
  prepared the 1.41.0 release
2019-05-16 11:42:35 +02:00
Fabien Potencier 0747f226f7 minor #3008 Tweak an error message (fabpot)
This PR was merged into the 1.x branch.

Discussion
----------

Tweak an error message

Commits
-------

19164de7 tweaked error messages
2019-05-16 11:37:12 +02:00
Fabien Potencier 19164de77b tweaked error messages 2019-05-16 11:32:52 +02:00
Fabien Potencier f81a1523c0 bug #3007 Fix wrong error message on "import" and "from" (fabpot)
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"
2019-05-16 11:28:20 +02:00
Fabien Potencier 118462c16d fixed wrong error message on "import" and "from" 2019-05-16 11:17:43 +02:00
Fabien Potencier f597addf79 bumped version to 2.10.1-DEV 2019-05-14 14:04:22 +02:00
Fabien Potencier 5240e21982 prepared the 2.10.0 release v2.10.0 2019-05-14 14:03:52 +02:00
Fabien Potencier b03f07e961 bumped version to 1.41.1-DEV 2019-05-14 13:59:47 +02:00
Fabien Potencier 575cd50283 prepared the 1.41.0 release v1.41.0 2019-05-14 13:59:08 +02:00
Fabien Potencier c304a3dded Merge branch '1.x' into 2.x
* 1.x:
  Correct Twig_SimpleFilter/Twig_SimpleFunction/Twig_SimpleTest deprecation doc (Revert: moved to namespaced classes by default)
  fixed PHP 7.4 support
2019-05-14 13:48:42 +02:00
Fabien Potencier a77e7f8f63 minor #3001 Correct Twig_SimpleFilter, Twig_SimpleFunction, Twig_SimpleTest deprecation doc (blankse)
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)
2019-05-14 13:41:12 +02:00
Sebastian Blank 65047482be Correct Twig_SimpleFilter/Twig_SimpleFunction/Twig_SimpleTest deprecation doc (Revert: moved to namespaced classes by default) 2019-05-14 12:17:20 +02:00
Fabien Potencier 44f02b2242 fixed PHP 7.4 support 2019-05-14 11:44:36 +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 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 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 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