Skip to content

Instantly share code, notes, and snippets.

@hjumeau
Created February 25, 2016 17:30
Show Gist options
  • Save hjumeau/8f24ca48d339f81568b7 to your computer and use it in GitHub Desktop.
Save hjumeau/8f24ca48d339f81568b7 to your computer and use it in GitHub Desktop.
WhitingHelpers
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
<h1>Welcome to {{appName}}</h1>
<br>
<br>
Your total is {{format-currency 250}}.
<br>
<br>
import Ember from 'ember';
export function formatCurrency(params/*, hash*/) {
let value = params[0],
dollars = Math.floor(value / 100),
cents = value % 100,
sign = "$";
if (cents.toString().length === 1) {
cents = '0' + cents;
}
return `${sign}${dollars}.${cents}`;
}
export default Ember.Helper.helper(formatCurrency);
{
"version": "0.6.0",
"EmberENV": {
"FEATURES": {}
},
"options": {
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "2.3.1",
"ember-data": "https://cdnjs.cloudflare.com/ajax/libs/ember-data.js/2.3.3/ember-data.js",
"ember-template-compiler": "2.3.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment