ember-cli中makeBoundHelper和registerBoundHelper之间的区别

rid*_*get 5 ember.js ember-cli

我试图创建一个自定义助手格式的值,余烬,CLI文档似乎表明我要么需要从我的助手文件内app.js内出口makeBoundHelper,或registerBoundHelper同时导入以前创建的辅助功能.

我对此的理解是否正确?或者您可以在帮助文件中使用registerBoundHelper并使其正确注册.

编辑

相关代码和错误信息如下:

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

只是registerBoundHelper推了推,使用"Uncaught TypeError:undefined is not function"中的结果

http://iamstef.net/ember-cli/下解决车把助手似乎表明,我只能从app.js内,但不知道利用registerBoundHelper如果这只是这样做是错误的情况下或IM.

the*_*ack 5

按照文档

makeBoundHelper是

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*
Run Code Online (Sandbox Code Playgroud)

所以基本上都做同样的工作.差异是registerBoundHelper公开的.参数也不同.

  @method registerBoundHelper
  @for Ember.Handlebars
  @param {String} name
  @param {Function} function
  @param {String} dependentKeys*
Run Code Online (Sandbox Code Playgroud)

makeBoundHelper不接受帮助程序的名称.您可能需要通过调用自己注册帮助程序

Ember.Handlebars.registerHelper(name, boundFn);
Run Code Online (Sandbox Code Playgroud)

boundFnmakeBoundHelper回调

  • 我想在`ember-cli`中使用`makeBoundHelper`会更好,因为它只是用文件名注册帮助器,如果它是虚线的... (2认同)