[Templates] Use templateLinker from MCTContainer

...for compatibility with both template and templateUrl.
This commit is contained in:
Victor Woeltjen 2016-02-26 14:24:41 -08:00
parent 741d4476e6
commit e61711688e
2 changed files with 6 additions and 17 deletions

View File

@ -319,6 +319,7 @@ define([
"key": "mctContainer",
"implementation": MCTContainer,
"depends": [
"templateLinker",
"containers[]"
]
},

View File

@ -42,18 +42,12 @@ define(
* @memberof platform/commonUI/general
* @constructor
*/
function MCTContainer(containers) {
function MCTContainer(templateLinker, containers) {
var containerMap = {};
// Initialize container map from extensions
containers.forEach(function (container) {
var key = container.key;
containerMap[key] = Object.create(container);
containerMap[key].templateUrl = [
container.bundle.path,
container.bundle.resources,
container.templateUrl
].join("/");
containerMap[container.key] = container;
});
return {
@ -73,9 +67,11 @@ define(
var key = attrs.key,
container = containerMap[key],
alias = "container",
copiedAttributes = {};
copiedAttributes = {},
changeTemplate = templateLinker.link(scope, element);
if (container) {
changeTemplate(container);
alias = container.alias || alias;
(container.attributes || []).forEach(function (attr) {
copiedAttributes[attr] = attrs[attr];
@ -83,15 +79,7 @@ define(
}
scope[alias] = copiedAttributes;
},
// Get the template URL for this container, based
// on its attributes.
templateUrl: function (element, attrs) {
var key = attrs.key;
return containerMap[key].templateUrl;
}
};
}