diff --git a/CHANGELOG.md b/CHANGELOG.md index ce77960..36f9061 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,12 @@ # Changelog -## v0.2.0 (2019-04-03) +## v0.2.1 (2019-04-25) +### Fixed +- Make regexp non-greedy where it's necessary ([#4](https://github.com/thepinecode/blade-filters/issues/4)) +### Changed +- Changed to boolean parameter for the currency filter +## v0.2.0 (2019-04-03) ### Changed - Move macros to their own class ([#2](https://github.com/thepinecode/blade-filters/pull/2)) diff --git a/README.md b/README.md index 8b508fa..5677053 100644 --- a/README.md +++ b/README.md @@ -92,9 +92,11 @@ The package comes with a few built-in filters, also the default Laravel string m ```php {{ '17.99' | currency:'CHF' }} // CHF 17.99 -{{ '17.99' | currency:'€','right' }} // 17.99 € +{{ '17.99' | currency:'€',false }} // 17.99 € ``` +> Passing `false` as the second parameter will align the symbol to the right. + #### Date ```php diff --git a/src/BladeFilters.php b/src/BladeFilters.php index a90392c..831e589 100644 --- a/src/BladeFilters.php +++ b/src/BladeFilters.php @@ -39,12 +39,12 @@ public static function __callStatic($method, $parameters) * * @param string $value * @param string $currency - * @param string $side + * @param bool $left * @return string */ - public static function currency($value, $currency = '$', $side = 'left') + public static function currency($value, $currency = '$', $left = true) { - return $side === 'left' ? "{$currency} {$value}" : "{$value} {$currency}"; + return $left ? "{$currency} {$value}" : "{$value} {$currency}"; } /** diff --git a/src/BladeFiltersCompiler.php b/src/BladeFiltersCompiler.php index b5c3b1d..8844217 100644 --- a/src/BladeFiltersCompiler.php +++ b/src/BladeFiltersCompiler.php @@ -16,7 +16,7 @@ protected function compileRegularEchos($value) { $value = parent::compileRegularEchos($value); - return preg_replace_callback('/(?<=<\?php\secho\se\()(.*)(?=\);\s\?>)/u', function ($matches) { + return preg_replace_callback('/(?<=<\?php\secho\se\()(.*?)(?=\);\s\?>)/u', function ($matches) { return $this->parseFilters($matches[0]); }, $value); }