[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", "key": "mctContainer",
"implementation": MCTContainer, "implementation": MCTContainer,
"depends": [ "depends": [
"templateLinker",
"containers[]" "containers[]"
] ]
}, },

View File

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