MCPcopy Create free account
hub / github.com/apache/cloudstack / compileTemplateUrl

Function compileTemplateUrl

tools/ngui/static/js/lib/angular.js:4487–4564  ·  view source on GitHub ↗
(directives, beforeTemplateNodeLinkFn, $compileNode, tAttrs,
        $rootElement, replace, childTranscludeFn)

Source from the content-addressed store, hash-verified

4485
4486
4487 function compileTemplateUrl(directives, beforeTemplateNodeLinkFn, $compileNode, tAttrs,
4488 $rootElement, replace, childTranscludeFn) {
4489 var linkQueue = [],
4490 afterTemplateNodeLinkFn,
4491 afterTemplateChildLinkFn,
4492 beforeTemplateCompileNode = $compileNode[0],
4493 origAsyncDirective = directives.shift(),
4494 // The fact that we have to copy and patch the directive seems wrong!
4495 derivedSyncDirective = extend({}, origAsyncDirective, {
4496 controller: null, templateUrl: null, transclude: null, scope: null
4497 });
4498
4499 $compileNode.html('');
4500
4501 $http.get(origAsyncDirective.templateUrl, {cache: $templateCache}).
4502 success(function(content) {
4503 var compileNode, tempTemplateAttrs, $template;
4504
4505 content = denormalizeTemplate(content);
4506
4507 if (replace) {
4508 $template = jqLite('<div>' + trim(content) + '</div>').contents();
4509 compileNode = $template[0];
4510
4511 if ($template.length != 1 || compileNode.nodeType !== 1) {
4512 throw new Error(MULTI_ROOT_TEMPLATE_ERROR + content);
4513 }
4514
4515 tempTemplateAttrs = {$attr: {}};
4516 replaceWith($rootElement, $compileNode, compileNode);
4517 collectDirectives(compileNode, directives, tempTemplateAttrs);
4518 mergeTemplateAttributes(tAttrs, tempTemplateAttrs);
4519 } else {
4520 compileNode = beforeTemplateCompileNode;
4521 $compileNode.html(content);
4522 }
4523
4524 directives.unshift(derivedSyncDirective);
4525 afterTemplateNodeLinkFn = applyDirectivesToNode(directives, compileNode, tAttrs, childTranscludeFn);
4526 afterTemplateChildLinkFn = compileNodes($compileNode[0].childNodes, childTranscludeFn);
4527
4528
4529 while(linkQueue.length) {
4530 var controller = linkQueue.pop(),
4531 linkRootElement = linkQueue.pop(),
4532 beforeTemplateLinkNode = linkQueue.pop(),
4533 scope = linkQueue.pop(),
4534 linkNode = compileNode;
4535
4536 if (beforeTemplateLinkNode !== beforeTemplateCompileNode) {
4537 // it was cloned therefore we have to clone as well.
4538 linkNode = JQLiteClone(compileNode);
4539 replaceWith(linkRootElement, jqLite(beforeTemplateLinkNode), linkNode);
4540 }
4541
4542 afterTemplateNodeLinkFn(function() {
4543 beforeTemplateNodeLinkFn(afterTemplateChildLinkFn, scope, linkNode, $rootElement, controller);
4544 }, scope, linkNode, $rootElement, controller);

Callers 1

applyDirectivesToNodeFunction · 0.85

Calls 11

extendFunction · 0.85
trimFunction · 0.85
replaceWithFunction · 0.85
collectDirectivesFunction · 0.85
mergeTemplateAttributesFunction · 0.85
applyDirectivesToNodeFunction · 0.85
compileNodesFunction · 0.85
JQLiteCloneFunction · 0.85
getMethod · 0.65
ErrorFunction · 0.50
errorMethod · 0.45

Tested by

no test coverage detected