From 6cfb99692ec588114501262f04731fe48a99109d Mon Sep 17 00:00:00 2001 From: Awilum Date: Thu, 7 May 2020 19:16:45 +0300 Subject: [PATCH] Twig 1.0.1 --- CHANGELOG.md | 10 ++++++ README.md | 2 +- plugin.yaml | 2 +- settings.yaml | 2 +- twig/ShortcodesTwigExtension.php | 53 ++++++++++++++++++++++++++++++++ 5 files changed, 66 insertions(+), 3 deletions(-) create mode 100644 twig/ShortcodesTwigExtension.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 18c291e..e730b20 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ + +# [1.0.1](https://github.com/flextype-plugins/twig/compare/v1.0.0...v1.0.1) (2020-05-07) + +### Features +* **core:** add new Shortcode Twig filter + + ``` + {{ entry.content|shortcode }} + ``` + # [1.0.0](https://github.com/flextype-plugins/twig) (2020-04-28) * Initial Release diff --git a/README.md b/README.md index 19b2532..1d72906 100755 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ The following dependencies need to be installed for Twig Plugin. | Item | Version | Download | |---|---|---| -| [flextype](https://github.com/flextype/flextype) | 0.9.8 | [download](https://github.com/flextype/flextype/releases/download/v0.9.8/flextype-0.9.8.zip) | +| [flextype](https://github.com/flextype/flextype) | 0.9.8 | [download](https://github.com/flextype/flextype/releases) | ## Installation diff --git a/plugin.yaml b/plugin.yaml index 0d53e23..b91f47b 100755 --- a/plugin.yaml +++ b/plugin.yaml @@ -1,5 +1,5 @@ name: Twig -version: 1.0.0 +version: 1.0.1 description: Twig plugin to present Twig template engine for Flextype. icon: fas fa-palette author: diff --git a/settings.yaml b/settings.yaml index 4fabb86..df459be 100644 --- a/settings.yaml +++ b/settings.yaml @@ -20,7 +20,7 @@ auto_reload: true cache: true debug: false charset: "UTF-8" -extensions: ['Cache', 'Entries', 'Emitter', 'I18n', 'Json', 'Yaml', 'Parser', 'Serializer', 'Markdown', 'Filesystem', 'Csrf', 'GlobalVars', 'Url', 'Registry'] +extensions: ['Cache', 'Entries', 'Emitter', 'I18n', 'Json', 'Yaml', 'Parser', 'Serializer', 'Markdown', 'Filesystem', 'Csrf', 'GlobalVars', 'Url', 'Registry', 'Shortcodes'] # Twig plugin priority priority: 100 diff --git a/twig/ShortcodesTwigExtension.php b/twig/ShortcodesTwigExtension.php new file mode 100644 index 0000000..06b9479 --- /dev/null +++ b/twig/ShortcodesTwigExtension.php @@ -0,0 +1,53 @@ +flextype = $flextype; + } + + /** + * Returns a list of filters to add to the existing list. + * + * @return array + */ + public function getFilters() : array + { + return [ + new Twig_SimpleFilter('shortcode', [$this, 'shortcode']), + ]; + } + + /** + * Shorcode process + */ + public function shortcode($value) : string + { + if ($value !== null) { + return $this->flextype->shortcodes->process($value); + } + + return ''; + } +}