在 Handlebars 中使用组件的完整路径
Use full path to component in Handlebars
我觉得问这个问题有点傻,但我也花了太多时间在这上面,似乎找不到答案。这是我的情况:
我正在使用带有 ember-cli 2.8 的 EmberJS 2.8。我在项目中使用 ember-cli-materialize 并且需要修改它的一个组件(md-input)作为解决方法,直到模块中的缺陷被修复(已经有一个 PR 用于修复模块)。
我在我的 components
目录中创建了我自己的 md-input
并且只是 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
});
问题是车把在我提供的路径中找不到组件。 Remember 我自己覆盖了组件,所以我不能只做 {{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
我知道这应该很简单,但我没有看到我做错了什么。如果有人能指出我正确的方向,我将不胜感激,谢谢!
您可以像这样直接在 package.json 中引用该拉取请求,如果这对您的情况有帮助的话:
ember-cli-materialize: "https://github.com/mike-north/ember-cli-materialize/pull/PULL_REQUEST_ID/head"
中指定
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
我觉得问这个问题有点傻,但我也花了太多时间在这上面,似乎找不到答案。这是我的情况:
我正在使用带有 ember-cli 2.8 的 EmberJS 2.8。我在项目中使用 ember-cli-materialize 并且需要修改它的一个组件(md-input)作为解决方法,直到模块中的缺陷被修复(已经有一个 PR 用于修复模块)。
我在我的 components
目录中创建了我自己的 md-input
并且只是 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
});
问题是车把在我提供的路径中找不到组件。 Remember 我自己覆盖了组件,所以我不能只做 {{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
我知道这应该很简单,但我没有看到我做错了什么。如果有人能指出我正确的方向,我将不胜感激,谢谢!
您可以像这样直接在 package.json 中引用该拉取请求,如果这对您的情况有帮助的话:
ember-cli-materialize: "https://github.com/mike-north/ember-cli-materialize/pull/PULL_REQUEST_ID/head"
中指定
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