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

Function compileTemplateUrl

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

Source from the content-addressed store, hash-verified

9792
9793
9794 function compileTemplateUrl(directives, $compileNode, tAttrs,
9795 $rootElement, childTranscludeFn, preLinkFns, postLinkFns, previousCompileContext) {
9796 var linkQueue = [],
9797 afterTemplateNodeLinkFn,
9798 afterTemplateChildLinkFn,
9799 beforeTemplateCompileNode = $compileNode[0],
9800 origAsyncDirective = directives.shift(),
9801 derivedSyncDirective = inherit(origAsyncDirective, {
9802 templateUrl: null, transclude: null, replace: null, $$originalDirective: origAsyncDirective
9803 }),
9804 templateUrl = (isFunction(origAsyncDirective.templateUrl))
9805 ? origAsyncDirective.templateUrl($compileNode, tAttrs)
9806 : origAsyncDirective.templateUrl,
9807 templateNamespace = origAsyncDirective.templateNamespace;
9808
9809 $compileNode.empty();
9810
9811 $templateRequest(templateUrl)
9812 .then(function(content) {
9813 var compileNode, tempTemplateAttrs, $template, childBoundTranscludeFn;
9814
9815 content = denormalizeTemplate(content);
9816
9817 if (origAsyncDirective.replace) {
9818 if (jqLiteIsTextNode(content)) {
9819 $template = [];
9820 } else {
9821 $template = removeComments(wrapTemplate(templateNamespace, trim(content)));
9822 }
9823 compileNode = $template[0];
9824
9825 if ($template.length !== 1 || compileNode.nodeType !== NODE_TYPE_ELEMENT) {
9826 throw $compileMinErr('tplrt',
9827 'Template for directive \'{0}\' must have exactly one root element. {1}',
9828 origAsyncDirective.name, templateUrl);
9829 }
9830
9831 tempTemplateAttrs = {$attr: {}};
9832 replaceWith($rootElement, $compileNode, compileNode);
9833 var templateDirectives = collectDirectives(compileNode, [], tempTemplateAttrs);
9834
9835 if (isObject(origAsyncDirective.scope)) {
9836 // the original directive that caused the template to be loaded async required
9837 // an isolate scope
9838 markDirectiveScope(templateDirectives, true);
9839 }
9840 directives = templateDirectives.concat(directives);
9841 mergeTemplateAttributes(tAttrs, tempTemplateAttrs);
9842 } else {
9843 compileNode = beforeTemplateCompileNode;
9844 $compileNode.html(content);
9845 }
9846
9847 directives.unshift(derivedSyncDirective);
9848
9849 afterTemplateNodeLinkFn = applyDirectivesToNode(directives, compileNode, tAttrs,
9850 childTranscludeFn, $compileNode, origAsyncDirective, preLinkFns, postLinkFns,
9851 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