JJ Abrams and custom template resolvers

There is a trick pattern mentioned by Robin Ward for resolving different templates for mobile which goes something like this:

App.Resolver = EmberDefaultResolver.extend({
  resolveTemplate: function(parsedName){
    var t = this._super(parsedName);
    if App.mobileActive){
        return this._super('mob_' + parsedName) || t;
    }
    return t;
  }
});

I’m using Ember-App-Kit which uses the jj-abrams resolver. AFIK this is an experimental resolver that may inform future versions of core. Is it possible to do the same thing with the new/experimental resolver? How? I’ve been contorting that code for a while and I can’t get it to do that trick.

Is the ease of extensibility there a feature to keep in the new resolver?

In Ember App Kit it should be possible to do something like the following:

import JJAbramsResolver from 'ember/resolver';
var AppkitResolver = JJAbramsResolver['default'];

var MyResolver = AppkitResolver.extend({
  resolveTemplate: function (parsedName) {
    // your code goes here
  }
});

export default MyResolver;

and you can use it in your app like:

import MyResolver from 'appkit/utils/my-resolver';

var App = Ember.Application.create({
  modulePrefix: 'appkit',
  Resolver: MyResolver
});

export default App;

BUT I have a follow up question as I need to override the #resolveTemplate() method after I called Ember.Application.create() and several things (like my custom ajax resolver) are set up properly… see here: ember.js - Ember App Kit: Set Resolver outside of Ember.Application.create() - Stack Overflow

In case some user with a knowledge in the Ember container takes a peek: is the Resolver also accessible throug the application container?

var MyResolver = AppkitResolver.extend({
  resolveTemplate: function (parsedName) {
    // your code goes here
  }
});

Sure that can be done, it’s just the "your code goes here" part needing clarification. Apparently the parsedName object has changed, before it was a string but now is an object with a few properties representing what the string used to. Evidently the important property is parsedName.fullNameWithoutType so I was able to do this with:

var CustomResolver = Resolver.extend({
    resolveTemplate: function(parsedName){
      var resolve = this._super(parsedName);
      if (['foo','bar'].indexOf(window.special_prop) > -1){
        var orig__parsedName_name = parsedName.name;
        parsedName.name = parsedName.name + '_' + window.special_prop;
        parsedName.fullName = parsedName.fullName + '_' + window.special_prop;
        parsedName.fullNameWithoutType = parsedName.fullNameWithoutType + '_' + window.special_prop;
        resolve this._super(parsedName) || resolve;
      }
      return resolve;
    }
});

So this is still possible, my only suggestion would be that there could be some comments on the parsedName object as its details are not very clear to an outside reader currently.