thefrontside / ember-let

Create variable bindings inside your handlebars templates
MIT License
52 stars 16 forks source link

Integration tests require calling `register-let-helper` initialize function #11

Closed taras closed 7 years ago

taras commented 7 years ago

Version of ember-let: 0.4.0

Ember Version / Ember CLI Version

Ember Version: any Ember CLI Version: 2.7.0

Expected Behavior

When using let helper in an addon, consumers of the addon should not have to know how my addon is created to do integration testing.

Actual Behavior

Integration tests fail with Error: Assertion Failed: A helper named "let" could not be found because let helper is not initialized.

Steps To Reproduce:

  1. Create an addon
  2. Install ember-let
  3. Add let helper to a template of a component
  4. Create an integration test that renders the component
  5. See the error

    Ember Twiddle / Example repo / Failing test:

Please create a reproduction of your bug with this ember-twiddle. This is extremely helpful and speeds up the debugging process.

taras commented 7 years ago

Related https://github.com/emberjs/ember.js/issues/12114 but for us this might be quiet problematic. Thoughts?

taras commented 7 years ago

I believe it's possible to turn let into a class helper. Let me know if you'd like me to look into this.

rwjblue commented 7 years ago

I believe it's possible to turn let into a class helper. Let me know if you'd like me to look into this.

There is no way to support the block param yielding with a class based helper.

taras commented 7 years ago

Thank you Robert.

rwjblue commented 7 years ago

Since the helper registration is not tied to the container/registry of the app being booted, it doesn't really need to exist in an initializer at all. One possible solution would be to have a simple vendor/ember-let/register.js file that does something (pseudo code) like this:

var registerHelper = Ember.__loader.require('ember-htmlbars/helpers').registerHelper;
var letKeywordModule = require('ember-let/-private/keyword').default; // => we would need to move the keyword implementation here
registerHelper('let', letKeyword);

Then we do this from the included hook:

app.import('vendor/ember-let/register.js');
taras commented 7 years ago

@rwjblue I created a WIP PR with your suggestion. It's not working at the moment because it seems that the vendor file is loaded before ember-let modules become available. Any idea why this might be?