From 53bccab32600a65876f52adfb36d82712f542fcb Mon Sep 17 00:00:00 2001 From: Andy Miller Date: Fri, 26 May 2017 17:52:19 -0600 Subject: [PATCH] Adde pathinfo twig function --- CHANGELOG.md | 1 + system/src/Grav/Common/Twig/TwigExtension.php | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 383d7eb08..5617e555b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ 1. [](#new) * Added new unified `Utils::getPagePathFromToken()` method which is used by various plugins (Admin, Forms, Downloads, etc.) * Added 165 new thumbnail images for use in `media.yaml` + * Added `pathinfo()` Twig function 1. [](#improved) * Optionally remove unpublished pages from the translated languages, move into untranslated list [#1482](https://github.com/getgrav/grav/pull/1482) * Improved reliability of `hash` file-check method diff --git a/system/src/Grav/Common/Twig/TwigExtension.php b/system/src/Grav/Common/Twig/TwigExtension.php index fc60bbdeb..b39dab620 100644 --- a/system/src/Grav/Common/Twig/TwigExtension.php +++ b/system/src/Grav/Common/Twig/TwigExtension.php @@ -115,6 +115,7 @@ class TwigExtension extends \Twig_Extension new \Twig_SimpleFunction('evaluate_twig', [$this, 'evaluateTwigFunc'], ['needs_context' => true, 'needs_environment' => true]), new \Twig_SimpleFunction('gist', [$this, 'gistFunc']), new \Twig_SimpleFunction('nonce_field', [$this, 'nonceFieldFunc']), + new \Twig_SimpleFunction('pathinfo', [$this, 'pathinfoFunc']), new \Twig_simpleFunction('random_string', [$this, 'randomStringFunc']), new \Twig_SimpleFunction('repeat', [$this, 'repeatFunc']), new \Twig_SimpleFunction('regex_replace', [$this, 'regexReplace']), @@ -1027,4 +1028,15 @@ class TwigExtension extends \Twig_Extension { var_dump($var); } + + /** + * Simple wrapper for pathinfo() + * + * @param $var + * @return mixed + */ + public function pathinfoFunc($var) + { + return pathinfo($var); + } }