Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ember - Sharing code between two EAK projects

I hava two emberjs projects both use EAK as the basic project structure. There are some common code i want to share between these two projects: templates, views(and the related stylesheets) some utility classes etc. But there are some doubts i want to figure out:

  1. Should i put the common code into a separate eak project?
  2. Should i use some package manager(bower maybe) to mange project dependency?
  3. EAK use its custom resolver to find ember classes under specific directories(views,controllers etc), so should i copy the common code into these directories or just extend the resolver to write my own finding logic?

Any push in the right direction will be a tremendous help! Thank you.

like image 672
merlin Avatar asked Feb 20 '26 12:02

merlin


1 Answers

It's perfectly find to extend the resolved to add directories as fault backs. Here's a sample code:

var appPath = "apps/ordering/";
var resolver = Ember.DefaultResolver.extend({
  resolveTemplate: function (parsedName) {
    parsedName.fullNameWithoutType = appPath + parsedName.fullNameWithoutType;
    # fallback to raw templates (used for compatibility with non-Ember/emblem templates)
    return this._super(parsedName) ||
      Ember.TEMPLATES[parsedName.fullNameWithoutType + ".raw"]
  }
});

Essentially you could call this._super with different paths in the right order to have the faultbacks.

Hope this helps

like image 84
Miguel Madero Avatar answered Feb 22 '26 01:02

Miguel Madero



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!