Skip to content
Permalink
Browse files

fix regex, change currency filter

  • Loading branch information...
iamgergo committed Apr 25, 2019
1 parent 13d3db4 commit ba210dabcbaffeb3e9ae9a330fbc88323f8151d7
Showing with 13 additions and 6 deletions.
  1. +6 −1 CHANGELOG.md
  2. +3 −1 README.md
  3. +3 −3 src/BladeFilters.php
  4. +1 −1 src/BladeFiltersCompiler.php
@@ -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))

@@ -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
@@ -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}";
}
/**
@@ -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);
}

0 comments on commit ba210da

Please sign in to comment.
You can’t perform that action at this time.