Skip to content

Commit

Permalink
fix regex, change currency filter
Browse files Browse the repository at this point in the history
  • Loading branch information
iamgergo committed Apr 25, 2019
1 parent 13d3db4 commit ba210da
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
7 changes: 6 additions & 1 deletion 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))

Expand Down
4 changes: 3 additions & 1 deletion README.md
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions src/BladeFilters.php
Expand Up @@ -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}";
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/BladeFiltersCompiler.php
Expand Up @@ -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);
}
Expand Down

0 comments on commit ba210da

Please sign in to comment.