Skip to content

Instantly share code, notes, and snippets.

@apcomplete
Last active August 29, 2015 14:18
Show Gist options
  • Save apcomplete/6bc05f64572d1439e452 to your computer and use it in GitHub Desktop.
Save apcomplete/6bc05f64572d1439e452 to your computer and use it in GitHub Desktop.
iris money formatting
require('./helpers');
.....
var Handlebars = require('hbsfy/runtime');
var accounting = require('accounting');
Handlebars.registerHelper('formatMoney', function(s) {
return accounting.formatMoney(s);
});
//auto load all other js files in folder
var fs = require('fs')
var files = fs.readdirSync(__dirname + '/');
files.forEach(function(file) {
if (file.match(/.+\.js/g) !== null && file !== 'index.js') {
var name = file.replace('.js', '');
exports[name] = require('./' + file);
}
});
<div>{{ formatMoney current.addons.total }}</div>
{{# ^ will output $100.00 or whatever the value is, properly formatted }}
@apcomplete
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment