FEATURE: allow plugins to overwrite handlebars templates

This commit is contained in:
Régis Hanol
2013-12-31 16:40:45 +01:00
parent d150bc20cf
commit 7fd88a52c9
6 changed files with 43 additions and 9 deletions

View File

@ -5,7 +5,7 @@ var lookup = function(lookupString, expectedTemplate, message) {
equal(Discourse.__container__.lookup(lookupString, {singleton: false}), expectedTemplate, message);
};
var setTemplates = function(lookupStrings) {
var setTemplates = function(lookupStrings) {
lookupStrings.forEach(function(lookupString) {
Ember.TEMPLATES[lookupString] = lookupString;
});
@ -95,6 +95,19 @@ test("resolves mobile templates to 'mobile/' namespace", function() {
lookup("template:baz", "baz", "falling back to a normal version when mobile version is not present");
});
test("resolves plugin templates to 'javascripts/' namespace", function() {
setTemplates([
"javascripts/foo",
"bar",
"javascripts/bar",
"baz"
]);
lookup("template:foo", "javascripts/foo", "finding plugin version even if normal one is not present");
lookup("template:bar", "javascripts/bar", "preferring plugin version when both versions are present");
lookup("template:baz", "baz", "falling back to a normal version when plugin version is not present");
});
test("resolves templates with 'admin' prefix to 'admin/templates/' namespace", function() {
setTemplates([
"admin/templates/foo",