More advanced ember-cli POD

Hello,

In my current ember application i’ve got the following structure:

  • /app/bundles/[feature]/controllers/featureController.js
  • /app/bundles/[feature]/controllers/featureItemController.js

And the same for views and models. One feature can have multiple views, moddels, controllers and templates

Is it possible to get this structure into ember-cli ?

2 Likes

Have a look at Ember.Resolver.moduleNameLookupPatterns(). You can add functions to this property that maps parsedNames into pathnames. This example is not complete, but if you turn on ENV.APP.LOG_RESOLVER you’ll see the resolutions as they are attempted in order, and you can tweak from there and add any additional lookups.

import Ember from 'ember';
import Resolver from 'ember/resolver';

Resolver.reopen({
  moduleNameLookupPatterns: Ember.computed(function () {
    'use strict';
    var defaults = this._super();
    return [
      this.featureResolver,
    ].concat(defaults);
  }),

  featureResolver(parsedName) {
    if (parsedName.type === 'controller') {
      var feature = parsedName.fullNameWithoutType;
      return "bundles/" + feature.pluralize() + "/" + parsedName.type.pluralize() + "/" + "feature" + parsedName.type).camelize();
    }
  },
  
});

thank you!. that looks like a good solution