Skip to content

Commit

Permalink
Adds support for the limit parameter in the "replace" filter. Bump …
Browse files Browse the repository at this point in the history
…to 1.0.1
  • Loading branch information
mmikkel committed Jun 7, 2018
1 parent b23b5f8 commit ba5d54f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).

## 1.0.1 - 2018-06-07
### Improved
- Adds support for the `limit` parameter in the "replace" filter (`preg_replace` wrapper)

## 1.0.0-beta1 - 2018-03-05
### Added
- Beta release
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "mmikkel/retcon",
"description": "A collection of powerful Twig filters for modifying HTML",
"type": "craft-plugin",
"version": "1.0.0",
"version": "1.0.1",
"keywords": [
"craft",
"cms",
Expand Down
5 changes: 3 additions & 2 deletions src/library/RetconApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,12 @@ public static function removeEmpty($html)
* @param $html
* @param $pattern
* @param string $replace
* @param int $limit
* @return null|string|string[]
*/
public static function replace($html, $pattern, $replace = '')
public static function replace($html, $pattern, $replace = '', $limit = -1)
{
return Retcon::$plugin->retcon->replace($html, $pattern, $replace);
return Retcon::$plugin->retcon->replace($html, $pattern, $replace, $limit);
}

}
5 changes: 3 additions & 2 deletions src/services/RetconService.php
Original file line number Diff line number Diff line change
Expand Up @@ -877,14 +877,15 @@ public function removeEmpty($html)
* @param $html
* @param $pattern
* @param string $replace
* @param int $limit
* @return null|string|string[]
*/
public function replace($html, $pattern, $replace = '')
public function replace($html, $pattern, $replace = '', $limit = -1)
{
if (!$html) {
return $html;
}
return preg_replace($pattern, $replace, $html);
return preg_replace($pattern, $replace, $html, $limit);
}

}

0 comments on commit ba5d54f

Please sign in to comment.