MCPcopy
hub / github.com/angular-ui/ui-grid / compileTemplateUrl

Function compileTemplateUrl

lib/test/angular/1.5.0/angular.js:9139–9252  ·  view source on GitHub ↗
(directives, $compileNode, tAttrs,
        $rootElement, childTranscludeFn, preLinkFns, postLinkFns, previousCompileContext)

Source from the content-addressed store, hash-verified

9137
9138
9139 function compileTemplateUrl(directives, $compileNode, tAttrs,
9140 $rootElement, childTranscludeFn, preLinkFns, postLinkFns, previousCompileContext) {
9141 var linkQueue = [],
9142 afterTemplateNodeLinkFn,
9143 afterTemplateChildLinkFn,
9144 beforeTemplateCompileNode = $compileNode[0],
9145 origAsyncDirective = directives.shift(),
9146 derivedSyncDirective = inherit(origAsyncDirective, {
9147 templateUrl: null, transclude: null, replace: null, $$originalDirective: origAsyncDirective
9148 }),
9149 templateUrl = (isFunction(origAsyncDirective.templateUrl))
9150 ? origAsyncDirective.templateUrl($compileNode, tAttrs)
9151 : origAsyncDirective.templateUrl,
9152 templateNamespace = origAsyncDirective.templateNamespace;
9153
9154 $compileNode.empty();
9155
9156 $templateRequest(templateUrl)
9157 .then(function(content) {
9158 var compileNode, tempTemplateAttrs, $template, childBoundTranscludeFn;
9159
9160 content = denormalizeTemplate(content);
9161
9162 if (origAsyncDirective.replace) {
9163 if (jqLiteIsTextNode(content)) {
9164 $template = [];
9165 } else {
9166 $template = removeComments(wrapTemplate(templateNamespace, trim(content)));
9167 }
9168 compileNode = $template[0];
9169
9170 if ($template.length != 1 || compileNode.nodeType !== NODE_TYPE_ELEMENT) {
9171 throw $compileMinErr('tplrt',
9172 "Template for directive '{0}' must have exactly one root element. {1}",
9173 origAsyncDirective.name, templateUrl);
9174 }
9175
9176 tempTemplateAttrs = {$attr: {}};
9177 replaceWith($rootElement, $compileNode, compileNode);
9178 var templateDirectives = collectDirectives(compileNode, [], tempTemplateAttrs);
9179
9180 if (isObject(origAsyncDirective.scope)) {
9181 // the original directive that caused the template to be loaded async required
9182 // an isolate scope
9183 markDirectiveScope(templateDirectives, true);
9184 }
9185 directives = templateDirectives.concat(directives);
9186 mergeTemplateAttributes(tAttrs, tempTemplateAttrs);
9187 } else {
9188 compileNode = beforeTemplateCompileNode;
9189 $compileNode.html(content);
9190 }
9191
9192 directives.unshift(derivedSyncDirective);
9193
9194 afterTemplateNodeLinkFn = applyDirectivesToNode(directives, compileNode, tAttrs,
9195 childTranscludeFn, $compileNode, origAsyncDirective, preLinkFns, postLinkFns,
9196 previousCompileContext);

Callers 1

applyDirectivesToNodeFunction · 0.70

Calls 15

inheritFunction · 0.70
isFunctionFunction · 0.70
jqLiteIsTextNodeFunction · 0.70
removeCommentsFunction · 0.70
wrapTemplateFunction · 0.70
trimFunction · 0.70
replaceWithFunction · 0.70
collectDirectivesFunction · 0.70
isObjectFunction · 0.70
markDirectiveScopeFunction · 0.70
mergeTemplateAttributesFunction · 0.70
applyDirectivesToNodeFunction · 0.70

Tested by

no test coverage detected