使用Handlebars中的组件的完整路径

时间:2016-10-13 12:07:09

标签: ember.js ember-cli

我觉得有点愚蠢的问这个,但我也花了太多时间在上面,似乎无法找到答案。这是我的情况:

我正在使用带有ember-cli 2.8的EmberJS 2.8。我在项目中使用ember-cli-materialize并需要修改其中一个组件(md-input)作为解决方法,直到模块中的缺陷得到修复(模块的修复已经有PR)。

我已在md-input目录中创建了自己的components,只需reopen() ember-cli-materialize组件即可添加我的修复程序。这很好。

我想要做的是添加一个集成测试,一旦我不再需要解决方法,它就会失败。我想我会通过在我的测试中明确地使用ember-cli-materialize组件并看看它是否符合我的预期来做到这一点。听起来很简单,我确信它是,但我似乎无法让它为我工作。我正在做类似以下的事情:

import hbs from 'htmlbars-inline-precompile';

test('check if md-input workaround needed', function (assert) {
  // a little setup here
  //...

  this.render(hbs`{{ember-cli-materialize.md-input label='Something' value='something else'}}`);
   //make a change and do my assertion here to see if things are still broken   
});

问题是把手在我提供的路径中找不到组件。请记住,我自己覆盖了该组件,因此我不能只执行{{md-input}},因为当我想使用ember-cli-materialize版本时,它会使用我的版本。我试图使用模板助手中的组件的多个路径,但没有成功:

ember-cli-materialize.md-input
ember-cli-materialize.components.md-input
ember-cli-materialize.templates.components.md-input 
ember-cli-materialize.templates.components.md-input 

我知道这应该很简单,但我没有看到我在这里做错了什么。如果有人能指出我正确的方向,我将不胜感激,谢谢!

1 个答案:

答案 0 :(得分:1)

您可以像这样直接在package.json中引用该请求,如果这有助于您的情况更好:

ember-cli-materialize: "https://github.com/mike-north/ember-cli-materialize/pull/PULL_REQUEST_ID/head"

正如npm docs

中所述
git://github.com/user/project.git#commit-ish
git+ssh://user@hostname:project.git#commit-ish
git+ssh://user@hostname/project.git#commit-ish
git+http://user@hostname/project/blah.git#commit-ish
git+https://user@hostname/project/blah.git#commit-ish