Skip to content

Commit

Permalink
V2.0.2 - added get_class filter
Browse files Browse the repository at this point in the history
  • Loading branch information
marionnewlevant committed Jan 31, 2018
1 parent 80f6d57 commit 48c192e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
5 changes: 5 additions & 0 deletions src/twigextensions/TwigPerversionTwigExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}),

];
}

Expand Down

0 comments on commit 48c192e

Please sign in to comment.