From 7febfbb2a7655390ff43ae9cb1ff5f09a5e5e71f Mon Sep 17 00:00:00 2001 From: Matias Griese Date: Mon, 20 Sep 2021 15:40:28 +0300 Subject: [PATCH 1/4] Improved support for Twig 2/3 --- CHANGELOG.md | 6 ++++++ classes/TwigExtension.php | 10 ---------- form.php | 21 ++++++++++++++++++--- 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 88e1916..0120dc3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# v5.1.2 +## 09/14/2021 + +1. [](#new) + * Improved support for Twig 2/3 + # v5.1.1 ## 09/14/2021 diff --git a/classes/TwigExtension.php b/classes/TwigExtension.php index 4cae01b..7bc93a6 100644 --- a/classes/TwigExtension.php +++ b/classes/TwigExtension.php @@ -12,16 +12,6 @@ */ class TwigExtension extends AbstractExtension { - /** - * Return a list of all filters. - * - * @return array - */ - public function getFilters(): array - { - return []; - } - /** * Return a list of all functions. * diff --git a/form.php b/form.php index 5344802..5f8625b 100644 --- a/form.php +++ b/form.php @@ -31,7 +31,9 @@ use RocketTheme\Toolbox\File\File; use RocketTheme\Toolbox\Event\Event; use RuntimeException; +use Twig\Environment; use Twig\Extension\CoreExtension; +use Twig\Extension\EscaperExtension; use Twig\TwigFunction; use function count; use function function_exists; @@ -355,10 +357,23 @@ public function onTwigInitialized(): void new TwigFunction('forms', [$this, 'getForm']) ); - $this->grav['twig']->twig()->getExtension(CoreExtension::class)->setEscaper('yaml', function ($twig, $string, $charset) { - return Yaml::dump($string); + if (Environment::VERSION_ID > 20000) { + // Twig 2/3 + $this->grav['twig']->twig()->getExtension(EscaperExtension::class)->setEscaper( + 'yaml', + function ($twig, $string, $charset) { + return Yaml::dump($string); + } + ); + } else { + // Twig 1.x + $this->grav['twig']->twig()->getExtension(CoreExtension::class)->setEscaper( + 'yaml', + function ($twig, $string, $charset) { + return Yaml::dump($string); + } + ); } - ); } From 3bcf7748a08efab685dfec2701539eacee6b501d Mon Sep 17 00:00:00 2001 From: Matias Griese Date: Mon, 20 Sep 2021 15:42:16 +0300 Subject: [PATCH 2/4] Changelog update --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0120dc3..4cd64c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ # v5.1.2 ## 09/14/2021 -1. [](#new) +1. [](#improved) * Improved support for Twig 2/3 # v5.1.1 From bf9d49621aea7003970016c18f8326c3a245b6ee Mon Sep 17 00:00:00 2001 From: Matias Griese Date: Mon, 20 Sep 2021 15:43:09 +0300 Subject: [PATCH 3/4] Fix date in changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4cd64c8..7ae01fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,5 @@ # v5.1.2 -## 09/14/2021 +## mm/dd/2021 1. [](#improved) * Improved support for Twig 2/3 From ec14e17d569563e22a5dcfdbab1934bca732cfc6 Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Wed, 29 Sep 2021 11:07:12 -0600 Subject: [PATCH 4/4] prepare for release --- CHANGELOG.md | 2 +- blueprints.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7ae01fb..ffda7b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,5 @@ # v5.1.2 -## mm/dd/2021 +## 09/29/2021 1. [](#improved) * Improved support for Twig 2/3 diff --git a/blueprints.yaml b/blueprints.yaml index 6f11ae7..aab8a6f 100644 --- a/blueprints.yaml +++ b/blueprints.yaml @@ -1,7 +1,7 @@ name: Form slug: form type: plugin -version: 5.1.1 +version: 5.1.2 description: Enables the forms handling icon: check-square author: