Search code examples
ember.jsember-cli

Use full path to component in Handlebars


I feel kind of dumb asking this but I have also spent too much time on it and can't seem to find an answer. Here is my situation:

I am using EmberJS 2.8 with ember-cli 2.8. I am using ember-cli-materialize in the project and need to modify one of its components(md-input) as a workaround until a defect in the module is fixed(there is already a PR up for the fix to the module).

I've created my own md-input in my components directory and simply reopen() the ember-cli-materialize component to add my fix. That works fine.

What I want to do is add an integration test that fails once the workaround I do is no longer necessary. I was thinking I would do that by simply explicitly using the ember-cli-materialize component in my test and seeing if it does what I expect. Sounds simple and I'm sure it is but I can't seem to get it to work for me. I am doing something like the following:

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   
});

The problem is handlebars can't find the component in the path I provide. Remember I override the component myself so I can't just do {{md-input}} because that will use my version when I want to use ember-cli-materialize version. I've tried to use multiple paths to the component in the template helper with no success:

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 

I know this should be simple but I'm not seeing what I'm doing wrong here. If anyone could point me in the right direction I would appreciate it, thanks!


Solution

  • You can reference that pull request directly in your package.json like this, if that helps your situation better:

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

    As specified in the 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