mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 23:58:31 -05:00
Fix resolve errors
This commit is contained in:
parent
3e408f9caa
commit
1948b41875
2 changed files with 15 additions and 9 deletions
|
@ -138,7 +138,18 @@ export default Ember.DefaultResolver.extend({
|
|||
},
|
||||
|
||||
findTemplate: function(parsedName) {
|
||||
return this._super(parsedName) || this.findSlashedTemplate(parsedName) || this.findAdminTemplate(parsedName) || this.findUnderscoredTemplate(parsedName);
|
||||
var withoutType = parsedName.fullNameWithoutType,
|
||||
slashedType = withoutType.replace(/\./g, '/'),
|
||||
decamelized = withoutType.decamelize(),
|
||||
templates = Ember.TEMPLATES;
|
||||
|
||||
return this._super(parsedName) ||
|
||||
templates[slashedType] ||
|
||||
templates[withoutType] ||
|
||||
templates[decamelized.replace(/\./, '/')] ||
|
||||
templates[decamelized.replace(/\_/, '/')] ||
|
||||
this.findAdminTemplate(parsedName) ||
|
||||
this.findUnderscoredTemplate(parsedName);
|
||||
},
|
||||
|
||||
findUnderscoredTemplate: function(parsedName) {
|
||||
|
@ -147,12 +158,6 @@ export default Ember.DefaultResolver.extend({
|
|||
return Ember.TEMPLATES[underscored];
|
||||
},
|
||||
|
||||
// Try to find a template with slash instead of first underscore, e.g. foo_bar_baz => foo/bar_baz
|
||||
findSlashedTemplate: function(parsedName) {
|
||||
var decamelized = parsedName.fullNameWithoutType.decamelize();
|
||||
return Ember.TEMPLATES[decamelized.replace("_", "/")] || Ember.TEMPLATES[decamelized.replace('.', '/')];
|
||||
},
|
||||
|
||||
// Try to find a template within a special admin namespace, e.g. adminEmail => admin/templates/email
|
||||
// (similar to how discourse lays out templates)
|
||||
findAdminTemplate: function(parsedName) {
|
||||
|
@ -160,7 +165,7 @@ export default Ember.DefaultResolver.extend({
|
|||
if (decamelized.indexOf('admin') === 0) {
|
||||
decamelized = decamelized.replace(/^admin\_/, 'admin/templates/');
|
||||
decamelized = decamelized.replace(/^admin\./, 'admin/templates/');
|
||||
decamelized = decamelized.replace(/\./, '_');
|
||||
decamelized = decamelized.replace(/\./g, '_');
|
||||
var dashed = decamelized.replace(/_/g, '-');
|
||||
return Ember.TEMPLATES[decamelized] || Ember.TEMPLATES[dashed];
|
||||
}
|
||||
|
|
|
@ -4,7 +4,8 @@ var originalTemplates, originalMobileViewFlag;
|
|||
var resolver = DiscourseResolver.create();
|
||||
|
||||
function lookupTemplate(name, expectedTemplate, message) {
|
||||
var result = resolver.resolveTemplate(resolver.parseName(name));
|
||||
var parseName = resolver.parseName(name);
|
||||
var result = resolver.resolveTemplate(parseName);
|
||||
equal(result, expectedTemplate, message);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue