Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

difference between makeBoundHelper and registerBoundHelper within ember-cli

I'm trying to create a custom helper to format a value, the ember-cli docs seem to indicate I either need to export makeBoundHelper from within my helper file, or registerBoundHelper from within app.js whilst importing the previously created helper function.

Is my understanding of this correct? Or can you use registerBoundHelper from within a helper file and have it register correctly.

EDIT

related code and error info below:

https://github.com/ridget/transactions/blob/master/app/helpers/to-currency.js

Just pushed that up, using registerBoundHelper results in "Uncaught TypeError: undefined is not a function"

http://iamstef.net/ember-cli/ under resolving handlebars helpers seems to indicate that I can only utilise registerBoundHelper from within app.js but not sure if this is the case or im just doing it wrong.

like image 605
ridget Avatar asked Jul 02 '14 06:07

ridget


1 Answers

As per docs

makeBoundHelper is

A (mostly) private helper function to `registerBoundHelper`. Takes the
  provided Handlebars helper function fn and returns it in wrapped
  bound helper form.

  @private
  @method makeBoundHelper
  @for Ember.Handlebars
  @param {Function} function
  @param {String} dependentKeys*

So basically both does same job. Difference is registerBoundHelper is available as public. Also parameters are different.

  @method registerBoundHelper
  @for Ember.Handlebars
  @param {String} name
  @param {Function} function
  @param {String} dependentKeys*

makeBoundHelper doesn't take name of the helper. You may need to register helper on your own by calling

Ember.Handlebars.registerHelper(name, boundFn);

boundFn is makeBoundHelper callback

like image 79
thecodejack Avatar answered Sep 30 '22 15:09

thecodejack