MCPcopy Index your code
hub / github.com/angular-ui/ui-router / compileTemplateUrl

Function compileTemplateUrl

test/angular/1.6/angular.js:10318–10435  ·  view source on GitHub ↗
(directives, $compileNode, tAttrs,
        $rootElement, childTranscludeFn, preLinkFns, postLinkFns, previousCompileContext)

Source from the content-addressed store, hash-verified

10316
10317
10318 function compileTemplateUrl(directives, $compileNode, tAttrs,
10319 $rootElement, childTranscludeFn, preLinkFns, postLinkFns, previousCompileContext) {
10320 var linkQueue = [],
10321 afterTemplateNodeLinkFn,
10322 afterTemplateChildLinkFn,
10323 beforeTemplateCompileNode = $compileNode[0],
10324 origAsyncDirective = directives.shift(),
10325 derivedSyncDirective = inherit(origAsyncDirective, {
10326 templateUrl: null, transclude: null, replace: null, $$originalDirective: origAsyncDirective
10327 }),
10328 templateUrl = (isFunction(origAsyncDirective.templateUrl))
10329 ? origAsyncDirective.templateUrl($compileNode, tAttrs)
10330 : origAsyncDirective.templateUrl,
10331 templateNamespace = origAsyncDirective.templateNamespace;
10332
10333 $compileNode.empty();
10334
10335 $templateRequest(templateUrl)
10336 .then(function(content) {
10337 var compileNode, tempTemplateAttrs, $template, childBoundTranscludeFn;
10338
10339 content = denormalizeTemplate(content);
10340
10341 if (origAsyncDirective.replace) {
10342 if (jqLiteIsTextNode(content)) {
10343 $template = [];
10344 } else {
10345 $template = removeComments(wrapTemplate(templateNamespace, trim(content)));
10346 }
10347 compileNode = $template[0];
10348
10349 if ($template.length !== 1 || compileNode.nodeType !== NODE_TYPE_ELEMENT) {
10350 throw $compileMinErr('tplrt',
10351 'Template for directive \'{0}\' must have exactly one root element. {1}',
10352 origAsyncDirective.name, templateUrl);
10353 }
10354
10355 tempTemplateAttrs = {$attr: {}};
10356 replaceWith($rootElement, $compileNode, compileNode);
10357 var templateDirectives = collectDirectives(compileNode, [], tempTemplateAttrs);
10358
10359 if (isObject(origAsyncDirective.scope)) {
10360 // the original directive that caused the template to be loaded async required
10361 // an isolate scope
10362 markDirectiveScope(templateDirectives, true);
10363 }
10364 directives = templateDirectives.concat(directives);
10365 mergeTemplateAttributes(tAttrs, tempTemplateAttrs);
10366 } else {
10367 compileNode = beforeTemplateCompileNode;
10368 $compileNode.html(content);
10369 }
10370
10371 directives.unshift(derivedSyncDirective);
10372
10373 afterTemplateNodeLinkFn = applyDirectivesToNode(directives, compileNode, tAttrs,
10374 childTranscludeFn, $compileNode, origAsyncDirective, preLinkFns, postLinkFns,
10375 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