diff --git a/CHANGELOG.md b/CHANGELOG.md index b67b006..c19fe1b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Twig Perversion Changelog +## 2.0.2 - 2018.01.31 +### Added +* Added `get_class` filter + ## 2.0.1 - 2017.12.13 ### Added * Added `array_splice` filter diff --git a/README.md b/README.md index 269ca3c..162dc1b 100644 --- a/README.md +++ b/README.md @@ -6,12 +6,17 @@ Making twig do things it really shouldn't. Twig is not intended to be a gene - `is numeric` test - `json_decode` filter - `array_splice` filter +- `get_class` filter ## Installation 1. Install with Composer via `composer require marionnewlevant/twig-perversion` from your project directory 2. Install plugin in the Craft Control Panel under Settings > Plugins +or + +1. Install via the Plugin Store + ## Using Twig Perversion ### Tags @@ -75,4 +80,7 @@ A macro with a `{% return %}` tag will return whatever the return value is (whic - **array_splice** Remove a portion of an array and replace it with something else. Uses the PHP [array_splice](http://php.net/manual/en/function.array-splice.php) function. Note that unlike the php function, this filter returns the modified array rather than the extracted elements. The original array is unchanged. Since the implementation requires copying the array, this will be less efficient than the raw php function. The **array_splice** filter is passed an `offset`, an optional `length`, and an optional `replacement`. +- **get_class** + Call PHP [get_class](http://php.net/manual/en/function.get-class.php) to return the class of an object as a string. + Brought to you by [Marion Newlevant](http://marion.newlevant.com) diff --git a/composer.json b/composer.json index d6c1949..01a92fe 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "marionnewlevant/twig-perversion", "description": "Making twig do things it really shouldn't", - "version": "2.0.1", + "version": "2.0.2", "type": "craft-plugin", "keywords": [ "craft", "craftcms", "plugin", "twigperversion" diff --git a/src/twigextensions/TwigPerversionTwigExtension.php b/src/twigextensions/TwigPerversionTwigExtension.php index 2d0dd35..57b676f 100644 --- a/src/twigextensions/TwigPerversionTwigExtension.php +++ b/src/twigextensions/TwigPerversionTwigExtension.php @@ -70,6 +70,11 @@ public function getFilters() $extracted = array_splice($input, $offset, $length, $replacement); return $input; }), + + new \Twig_Filter('get_class', function($obj) { + return get_class($obj); + }), + ]; }