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

Function compileTemplateUrl

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

Source from the content-addressed store, hash-verified

8736
8737
8738 function compileTemplateUrl(directives, $compileNode, tAttrs,
8739 $rootElement, childTranscludeFn, preLinkFns, postLinkFns, previousCompileContext) {
8740 var linkQueue = [],
8741 afterTemplateNodeLinkFn,
8742 afterTemplateChildLinkFn,
8743 beforeTemplateCompileNode = $compileNode[0],
8744 origAsyncDirective = directives.shift(),
8745 derivedSyncDirective = inherit(origAsyncDirective, {
8746 templateUrl: null, transclude: null, replace: null, $$originalDirective: origAsyncDirective
8747 }),
8748 templateUrl = (isFunction(origAsyncDirective.templateUrl))
8749 ? origAsyncDirective.templateUrl($compileNode, tAttrs)
8750 : origAsyncDirective.templateUrl,
8751 templateNamespace = origAsyncDirective.templateNamespace;
8752
8753 $compileNode.empty();
8754
8755 $templateRequest(templateUrl)
8756 .then(function(content) {
8757 var compileNode, tempTemplateAttrs, $template, childBoundTranscludeFn;
8758
8759 content = denormalizeTemplate(content);
8760
8761 if (origAsyncDirective.replace) {
8762 if (jqLiteIsTextNode(content)) {
8763 $template = [];
8764 } else {
8765 $template = removeComments(wrapTemplate(templateNamespace, trim(content)));
8766 }
8767 compileNode = $template[0];
8768
8769 if ($template.length != 1 || compileNode.nodeType !== NODE_TYPE_ELEMENT) {
8770 throw $compileMinErr('tplrt',
8771 "Template for directive '{0}' must have exactly one root element. {1}",
8772 origAsyncDirective.name, templateUrl);
8773 }
8774
8775 tempTemplateAttrs = {$attr: {}};
8776 replaceWith($rootElement, $compileNode, compileNode);
8777 var templateDirectives = collectDirectives(compileNode, [], tempTemplateAttrs);
8778
8779 if (isObject(origAsyncDirective.scope)) {
8780 // the original directive that caused the template to be loaded async required
8781 // an isolate scope
8782 markDirectiveScope(templateDirectives, true);
8783 }
8784 directives = templateDirectives.concat(directives);
8785 mergeTemplateAttributes(tAttrs, tempTemplateAttrs);
8786 } else {
8787 compileNode = beforeTemplateCompileNode;
8788 $compileNode.html(content);
8789 }
8790
8791 directives.unshift(derivedSyncDirective);
8792
8793 afterTemplateNodeLinkFn = applyDirectivesToNode(directives, compileNode, tAttrs,
8794 childTranscludeFn, $compileNode, origAsyncDirective, preLinkFns, postLinkFns,
8795 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