I am currently upgrading from Ember 1.8.1 to Ember 1.13.9. My App is sort of oldschool by NOT using the ember-cli (no es6 whatever syntax).
How do i replace the deprecated Ember.Handlebars.registerBoundHelper properly:
Ember.Handlebars.registerBoundHelper('date-ago',function(date) {
return moment.utc(date).fromNow();
});
will advice you to
DEPRECATION: `Ember.Handlebars.registerBoundHelper` is deprecated.
Please refactor to use `Ember.Helpers.helper`.
[deprecation id: ember-htmlbars.register-bound-helper]
So i thought replacing ´Ember.Handlebars.registerBoundHelper´ with ´Ember.Helper.helper´ would do, but then these helpers are not available any more: "Uncaught Error: Assertion Failed: A helper named 'date-ago' could not be found!".
How do I register a htmlbars helper in Ember 2.0 without ES6 syntax or ember-cli magic?
Just assign it to Application:
App.FormatCurrencyHelper = Ember.Helper.helper(function(params, hash) {
var cents = params[0];
var currency = hash.currency;
return currency + cents * 0.01;
});
//template
{{format-currency 75 currency="$"}}
jsbin here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With