lundi 25 mai 2020

Extend blueprint in EmberJS

Is there a way to extend blueprint in EmberJS? As far as I know, I can override a blueprint:

Blueprints in your project’s directory take precedence over those packaged with Ember CLI. This makes it easy to override the built-in blueprints by generating one with the same name.

But it seems I have to copy-paste some JS and the template itself. I would like to change the default template a bit, without breaking the actual template and template behavior.

By example, let's say I would like to replace only one line in this template:

import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';

module('<%= friendlyTestDescription %>', function(hooks) {
  setupTest(hooks);

  // TODO: Replace this with your real tests.
  test('it exists', function(assert) {
    let controller = this.owner.lookup('controller:<%= controllerPathName %>');
    assert.ok(controller);
  });
}); 

I would like to change only one line (let vs const:

    const controller = this.owner.lookup('controller:<%= controllerPathName %>');

I don't want to rewrite the whole index file plus the blueprint template file, it seems overkill. Is it possible?




Aucun commentaire:

Enregistrer un commentaire