Skip to content

Instantly share code, notes, and snippets.

@chrislopresto
Created April 27, 2015 19:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chrislopresto/1fd05e2086cbb15cfee5 to your computer and use it in GitHub Desktop.
Save chrislopresto/1fd05e2086cbb15cfee5 to your computer and use it in GitHub Desktop.
Pod Structure Filenames

This allows for a pod structure of:

  • app
    • components
      • vimeo-video
        • vimeo-video-component.js
        • vimeo-video-template.hbs
import Resolver from './resolver';
// Allow pod templates that aren't named template.hbs
app._podTemplatePatterns = function() {
return this.registry.extensionsForType('template').map(function(extension) {
return new RegExp('\.(.+\.)?' + extension + '$');
});
};
import Ember from 'ember';
import Resolver from 'ember/resolver';
export default Resolver.extend({
podBasedLookupWithPrefixWithName: function(podPrefix, parsedName) {
var fullNameWithoutType = parsedName.fullNameWithoutType;
if (parsedName.type === 'template') {
fullNameWithoutType = fullNameWithoutType.replace(/^components\//, '');
}
return podPrefix + '/' + fullNameWithoutType + '/' + fullNameWithoutType + '-' + parsedName.type;
},
podBasedComponentsInSubdirWithName: function(parsedName) {
var podPrefix = this.namespace.podModulePrefix || this.namespace.modulePrefix;
podPrefix = podPrefix + '/components';
if (parsedName.type === 'component' || parsedName.fullNameWithoutType.match(/^components/)) {
return this.podBasedLookupWithPrefixWithName(podPrefix, parsedName);
}
},
moduleNameLookupPatterns: Ember.computed(function(){
var patterns = this._super();
patterns.unshiftObject(this.podBasedComponentsInSubdirWithName);
return patterns;
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment