resolver.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import Ember from 'ember';
  2. import Resolver from 'ember/resolver';
  3. export default Resolver.extend({
  4. _startsWith: function(string, beginning) {
  5. return string.indexOf(beginning) === 0;
  6. },
  7. _endsWith: function(string, tail) {
  8. return string.indexOf(tail, string.length - tail.length) !== -1;
  9. },
  10. misagoFormModuleName: function(parsedName) {
  11. if (this._endsWith(parsedName.name, '-form')) {
  12. var isComponent = parsedName.type === 'component';
  13. var isComponentTemplate = this._startsWith(parsedName.name, 'components/');
  14. if (isComponent || isComponentTemplate) {
  15. var path = parsedName.prefix + '/' + this.pluralize(parsedName.type) + '/';
  16. if (isComponentTemplate) {
  17. path += 'components/forms/' + parsedName.fullNameWithoutType.substr(11);
  18. } else {
  19. path += 'forms/' + parsedName.fullNameWithoutType;
  20. }
  21. console.log(path);
  22. return path;
  23. }
  24. }
  25. },
  26. // register custom lookup
  27. moduleNameLookupPatterns: Ember.computed(function(){
  28. return Ember.A([
  29. this.misagoFormModuleName,
  30. this.podBasedModuleName,
  31. this.podBasedComponentsInSubdir,
  32. this.mainModuleName,
  33. this.defaultModuleName
  34. ]);
  35. })
  36. });