Skip to content

Commit

Permalink
update doc
Browse files Browse the repository at this point in the history
  • Loading branch information
cedric-g committed Jun 12, 2012
1 parent d9543ec commit a17e3f1
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,40 @@ In the commanda line `ecb` is the value returned by the `getIdentifier()` method
```
./app/console lexik:currency:import ecb
```

Usage
=====

##### In a twig template

Just use the `currency_format` filter:

```
{% set targetCurrency = 'EUR' %}
{{ amount | currency_format(targetCurrency) }}
```

You can also pass more arguments, to display or not decimal and the currency symbol. And you can specify the amount's currency if needed.

```
{% set targetCurrency = 'EUR' %}
{% set amountCurrency = 'USD' %}
{% set decimal = false %}
{% set symbol = true %}
{{ amount | currency_format(targetCurrency, decimal, symbol, amountCurrency) }}
```

##### By using the service

Use the `convert()` method from the `lexik_currency.converter` service:

```php
<?php
// by default the amount will rounded and the amount have to be in the default currency
$convertedAmount = $container->get('lexik_currency.converter')->convert($amount, $targetCurrency);

// here the amount won't be rounded and we specify that $amount currency is 'USD'
$convertedAmount = $container->get('lexik_currency.converter')->convert($amount, $targetCurrency, false, 'USD');
```

0 comments on commit a17e3f1

Please sign in to comment.