https://github.com/tim-evans/maguire.js
A small client-side library that works in conjunction with maguire to format money.
https://github.com/tim-evans/maguire.js
Last synced: about 1 year ago
JSON representation
A small client-side library that works in conjunction with maguire to format money.
- Host: GitHub
- URL: https://github.com/tim-evans/maguire.js
- Owner: tim-evans
- License: mit
- Created: 2015-04-21T17:38:56.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2015-01-09T20:03:44.000Z (over 11 years ago)
- Last Synced: 2025-03-24T06:04:05.545Z (about 1 year ago)
- Language: JavaScript
- Size: 266 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Maguire.js
A small client-side library that works in conjunction with maguire to format money.
### Configuring the library
Maguire.js doesn't come with any locale / currency support by default. It's designed to get data from your server tailored to the needs of the specific end user.
If maguire.js is being used in conjunction with maguire for Ruby, the following snippit should do the trick:
```javascript
var maguire = require('maguire');
// Register currencies for this user
$.getJSON('/currencies', function (currencies) {
currencies.forEach(maguire.registerCurrency);
});
$.getJSON('/locale', function (locale) {
maguire.registerLocale(locale.id, locale);
});
```
### Formatting
Once configured, you may start formatting your money:
```javascript
var format = require('maguire').format;
format({ value: 2000, currency: 'USD' });
// => $20.00
```