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

Function compileTemplateUrl

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

Source from the content-addressed store, hash-verified

7929
7930
7931 function compileTemplateUrl(directives, $compileNode, tAttrs,
7932 $rootElement, childTranscludeFn, preLinkFns, postLinkFns, previousCompileContext) {
7933 var linkQueue = [],
7934 afterTemplateNodeLinkFn,
7935 afterTemplateChildLinkFn,
7936 beforeTemplateCompileNode = $compileNode[0],
7937 origAsyncDirective = directives.shift(),
7938 derivedSyncDirective = inherit(origAsyncDirective, {
7939 templateUrl: null, transclude: null, replace: null, $$originalDirective: origAsyncDirective
7940 }),
7941 templateUrl = (isFunction(origAsyncDirective.templateUrl))
7942 ? origAsyncDirective.templateUrl($compileNode, tAttrs)
7943 : origAsyncDirective.templateUrl,
7944 templateNamespace = origAsyncDirective.templateNamespace;
7945
7946 $compileNode.empty();
7947
7948 $templateRequest(templateUrl)
7949 .then(function(content) {
7950 var compileNode, tempTemplateAttrs, $template, childBoundTranscludeFn;
7951
7952 content = denormalizeTemplate(content);
7953
7954 if (origAsyncDirective.replace) {
7955 if (jqLiteIsTextNode(content)) {
7956 $template = [];
7957 } else {
7958 $template = removeComments(wrapTemplate(templateNamespace, trim(content)));
7959 }
7960 compileNode = $template[0];
7961
7962 if ($template.length != 1 || compileNode.nodeType !== NODE_TYPE_ELEMENT) {
7963 throw $compileMinErr('tplrt',
7964 "Template for directive '{0}' must have exactly one root element. {1}",
7965 origAsyncDirective.name, templateUrl);
7966 }
7967
7968 tempTemplateAttrs = {$attr: {}};
7969 replaceWith($rootElement, $compileNode, compileNode);
7970 var templateDirectives = collectDirectives(compileNode, [], tempTemplateAttrs);
7971
7972 if (isObject(origAsyncDirective.scope)) {
7973 markDirectivesAsIsolate(templateDirectives);
7974 }
7975 directives = templateDirectives.concat(directives);
7976 mergeTemplateAttributes(tAttrs, tempTemplateAttrs);
7977 } else {
7978 compileNode = beforeTemplateCompileNode;
7979 $compileNode.html(content);
7980 }
7981
7982 directives.unshift(derivedSyncDirective);
7983
7984 afterTemplateNodeLinkFn = applyDirectivesToNode(directives, compileNode, tAttrs,
7985 childTranscludeFn, $compileNode, origAsyncDirective, preLinkFns, postLinkFns,
7986 previousCompileContext);
7987 forEach($rootElement, function(node, i) {
7988 if (node == compileNode) {

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
markDirectivesAsIsolateFunction · 0.70
mergeTemplateAttributesFunction · 0.70
applyDirectivesToNodeFunction · 0.70

Tested by

no test coverage detected