3.0.0 • Published 10 years ago

accounting-helpers v3.0.0

Weekly downloads
13
License
MIT
Repository
github
Last release
10 years ago

accounting-helpers

Stache helpers for formatting money.

npm version

NPM

Installation

npm install accounting-helpers --save

Usage

Using CanJS's built-in support for StealJS, you can now import the module directly inside your templates. For example, assuming we have a variable amount which holds the value 2333.

<can-import from="accounting-helpers"/>

This will return 2,333.00:
{{formatMoney amount}}

This will return 23.33:
{{formatCents amount}}

The two examples above will include live binding. To opt out use the Unbound options, like this:

<can-import from="accounting-helpers"/>

This will return 2,333.00 without live binding:
{{formatMoneyUnbound amount}}

This will return 23.33 without live binding:
{{formatCentsUnbound amount}}

Use individual helpers in can-component

If you need to, you can import the helpers individually.

import Component from 'can-component';
import formatMoney from "accounting-helpers/format-money";
import formatMoneyUnbound from "accounting-helpers/format-money-unbound";
import formatCents from "accounting-helpers/format-cents";
import formatCentsUnbound from "accounting-helpers/format-cents-unbound";

Component.extend({
  tag: "hello-world",
  template: stache("{{formatMoney amount}}"),
  viewModel: {
    amount: 300,
  },
  helpers: {
    formatMoney,
    formatMoneyUnbound,
    formatCents,
    formatCentsUnbound
  }
});

Contributing

Pull requests are welcome. Analyze the code. See where it needs improvement, and let me know. Please, help make it better!

Changelog

  • 3.0.0 - CanJS 3.0 compatibility.
  • 1.0.0 - CanJS 2.3 compatibility.

Authors

Built with StealJS

3.0.0

10 years ago

0.1.4

10 years ago

0.1.3

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago