diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d7b40d..f21e190 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/composer.json b/composer.json index ffa1959..da39c3d 100644 --- a/composer.json +++ b/composer.json @@ -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", diff --git a/src/library/RetconApi.php b/src/library/RetconApi.php index b2f9006..83b4ab5 100644 --- a/src/library/RetconApi.php +++ b/src/library/RetconApi.php @@ -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); } } diff --git a/src/services/RetconService.php b/src/services/RetconService.php index dda3df2..12bca99 100644 --- a/src/services/RetconService.php +++ b/src/services/RetconService.php @@ -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); } }