From eb9a3e245e69143795dd7b6f37873b7ec7c140c2 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 3 Jun 2019 18:44:27 +0200 Subject: [PATCH 1/7] updated CHANGELOG --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index a65a5958c..620975a1c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,6 @@ * 2.11.1 (2019-XX-XX) + * added support for "Twig\Markup" instances in the "in" test (again) * allowed string operators as variables names in assignments * fixed support for macros defined in parent templates From ee7be2e18721fa158658a429b6df83ed414da6db Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 4 Jun 2019 10:04:49 +0200 Subject: [PATCH 2/7] added a doc note --- doc/tags/macro.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/doc/tags/macro.rst b/doc/tags/macro.rst index 4d79f2f8a..33808f5a8 100644 --- a/doc/tags/macro.rst +++ b/doc/tags/macro.rst @@ -138,6 +138,12 @@ When calling ``import`` or ``from`` from a ``macro`` tag, the imported macros are only defined in the current macro and they override macros defined at the template level with the same names. +.. note:: + + Before Twig 2.11, it was possible to use macros imported in a block in a + "sub-block". When upgrading to 2.11, you need to either move the import in + the global scope or reimport the macros explicitly in the "sub-blocks". + Checking if a Macro is defined ------------------------------ From 671347603760a88b1e7288aaa9378f33687d7edf Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 4 Jun 2019 13:31:08 +0200 Subject: [PATCH 3/7] prepared the 1.42.1 release --- CHANGELOG | 2 +- ext/twig/php_twig.h | 2 +- src/Environment.php | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 1f5a4cbe3..c684ad08b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,4 @@ -* 1.42.1 (2019-XX-XX) +* 1.42.1 (2019-06-04) * added support for "Twig\Markup" instances in the "in" test (again) * allowed string operators as variables names in assignments diff --git a/ext/twig/php_twig.h b/ext/twig/php_twig.h index 361c05a42..c5c463786 100644 --- a/ext/twig/php_twig.h +++ b/ext/twig/php_twig.h @@ -15,7 +15,7 @@ #ifndef PHP_TWIG_H #define PHP_TWIG_H -#define PHP_TWIG_VERSION "1.42.1-DEV" +#define PHP_TWIG_VERSION "1.42.1" #include "php.h" diff --git a/src/Environment.php b/src/Environment.php index fec9c0725..38688d86b 100644 --- a/src/Environment.php +++ b/src/Environment.php @@ -41,12 +41,12 @@ use Twig\TokenParser\TokenParserInterface; */ class Environment { - const VERSION = '1.42.1-DEV'; + const VERSION = '1.42.1'; const VERSION_ID = 14201; const MAJOR_VERSION = 1; const MINOR_VERSION = 42; const RELEASE_VERSION = 1; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; protected $charset; protected $loader; From e0ee3b5e44ea46dafe38497c61990ab8460ba3d2 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 4 Jun 2019 13:31:48 +0200 Subject: [PATCH 4/7] bumped version to 1.42.2-DEV --- CHANGELOG | 4 ++++ ext/twig/php_twig.h | 2 +- src/Environment.php | 8 ++++---- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index c684ad08b..1a0560ec5 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,7 @@ +* 1.42.2 (2019-XX-XX) + + * n/a + * 1.42.1 (2019-06-04) * added support for "Twig\Markup" instances in the "in" test (again) diff --git a/ext/twig/php_twig.h b/ext/twig/php_twig.h index c5c463786..3bbfe9480 100644 --- a/ext/twig/php_twig.h +++ b/ext/twig/php_twig.h @@ -15,7 +15,7 @@ #ifndef PHP_TWIG_H #define PHP_TWIG_H -#define PHP_TWIG_VERSION "1.42.1" +#define PHP_TWIG_VERSION "1.42.2-DEV" #include "php.h" diff --git a/src/Environment.php b/src/Environment.php index 38688d86b..d61c1fd20 100644 --- a/src/Environment.php +++ b/src/Environment.php @@ -41,12 +41,12 @@ use Twig\TokenParser\TokenParserInterface; */ class Environment { - const VERSION = '1.42.1'; - const VERSION_ID = 14201; + const VERSION = '1.42.2-DEV'; + const VERSION_ID = 14202; const MAJOR_VERSION = 1; const MINOR_VERSION = 42; - const RELEASE_VERSION = 1; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 2; + const EXTRA_VERSION = 'DEV'; protected $charset; protected $loader; From 0418e17113266e84c03ccf758680af8abc4b22dc Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 4 Jun 2019 13:32:47 +0200 Subject: [PATCH 5/7] prepared the 2.11.1 release --- CHANGELOG | 2 +- src/Environment.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 620975a1c..0d71a8787 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,4 @@ -* 2.11.1 (2019-XX-XX) +* 2.11.1 (2019-06-04) * added support for "Twig\Markup" instances in the "in" test (again) * allowed string operators as variables names in assignments diff --git a/src/Environment.php b/src/Environment.php index 7da430eb3..243695f4a 100644 --- a/src/Environment.php +++ b/src/Environment.php @@ -38,12 +38,12 @@ use Twig\TokenParser\TokenParserInterface; */ class Environment { - const VERSION = '2.11.1-DEV'; + const VERSION = '2.11.1'; const VERSION_ID = 21101; const MAJOR_VERSION = 2; const MINOR_VERSION = 11; const RELEASE_VERSION = 1; - const EXTRA_VERSION = 'DEV'; + const EXTRA_VERSION = ''; private $charset; private $loader; From 3cd635bf91edde65a05cdb05c40d953f489ffa8a Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 4 Jun 2019 13:33:20 +0200 Subject: [PATCH 6/7] bumped version to 2.11.2-DEV --- CHANGELOG | 4 ++++ src/Environment.php | 8 ++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 0d71a8787..dc0824d56 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,7 @@ +* 2.11.2 (2019-XX-XX) + + * n/a + * 2.11.1 (2019-06-04) * added support for "Twig\Markup" instances in the "in" test (again) diff --git a/src/Environment.php b/src/Environment.php index 243695f4a..e8acb49db 100644 --- a/src/Environment.php +++ b/src/Environment.php @@ -38,12 +38,12 @@ use Twig\TokenParser\TokenParserInterface; */ class Environment { - const VERSION = '2.11.1'; - const VERSION_ID = 21101; + const VERSION = '2.11.2-DEV'; + const VERSION_ID = 21102; const MAJOR_VERSION = 2; const MINOR_VERSION = 11; - const RELEASE_VERSION = 1; - const EXTRA_VERSION = ''; + const RELEASE_VERSION = 2; + const EXTRA_VERSION = 'DEV'; private $charset; private $loader; From 18e37286824acf4fa125110a3781258522a31fb3 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Tue, 4 Jun 2019 17:49:11 +0200 Subject: [PATCH 7/7] removed docs about overloading --- doc/advanced.rst | 43 ------------------------------------------- 1 file changed, 43 deletions(-) diff --git a/doc/advanced.rst b/doc/advanced.rst index fd9588358..29252275b 100644 --- a/doc/advanced.rst +++ b/doc/advanced.rst @@ -908,49 +908,6 @@ It is now possible to move the runtime logic to a new } } -Overloading ------------ - -To overload an already defined filter, test, operator, global variable, or -function, re-define it in an extension and register it **as late as -possible** (order matters):: - - class MyCoreExtension extends \Twig\Extension\AbstractExtension - { - public function getFilters() - { - return [ - new \Twig\TwigFilter('date', [$this, 'dateFilter']), - ]; - } - - public function dateFilter($timestamp, $format = 'F j, Y H:i') - { - // do something different from the built-in date filter - } - } - - $twig = new \Twig\Environment($loader); - $twig->addExtension(new MyCoreExtension()); - -Here, we have overloaded the built-in ``date`` filter with a custom one. - -If you do the same on the ``\Twig\Environment`` itself, beware that it takes -precedence over any other registered extensions:: - - $twig = new \Twig\Environment($loader); - $twig->addFilter(new \Twig\TwigFilter('date', function ($timestamp, $format = 'F j, Y H:i') { - // do something different from the built-in date filter - })); - // the date filter will come from the above registration, not - // from the registered extension below - $twig->addExtension(new MyCoreExtension()); - -.. caution:: - - Note that overloading the built-in Twig elements is not recommended as it - might be confusing. - Testing an Extension --------------------