Smart package for Accounting.js by Joss Crowcroft.
accounting.js is a tiny JavaScript library for number, money and currency formatting, with optional excel-style column rendering (to line up symbols and decimals). It's lightweight, fully localisable and has zero dependencies.
See the Accounting.js website for documentation.
Install using standard meteor:
meteor install iain:accounting
Use in Javascript by importing (for example in server/main.js
of a fresh
meteor project):
import { Meteor } from 'meteor/meteor';
import { accounting } from 'meteor/iain:accounting';
Meteor.startup(() => {
// code to run on server at startup
console.log(accounting.formatMoney(123456789))
});
In your Javascript for your template (e.g. asset.js
):
import { Template } from 'meteor/templating';
import { accounting } from 'meteor/iain:accounting';
Template.asset.helpers({
formatCurrency(value) {
return accounting.formatMoney(value);
},
});
In your template (e.g. asset.html
)
<template name="asset">
{{formatCurrency initialValue}}
</template>