MDL-63667 output: Fix for recursive templates

A template can include itself - e.g. by looping over the context children and rendering a tree.

Ensure this promise still resolves.

Example: admin/tool/lp/templates/competencies_tree.mustache.
This commit is contained in:
Damyon Wiese
2018-10-18 10:40:31 +08:00
parent 3212e7aaef
commit b51c5b929f
2 changed files with 6 additions and 2 deletions

File diff suppressed because one or more lines are too long

View File

@@ -659,7 +659,11 @@ define(['core/mustache',
var cachePartialPromise = this.getTemplate(templateName).then(function(templateSource) { var cachePartialPromise = this.getTemplate(templateName).then(function(templateSource) {
var partials = this.scanForPartials(templateSource); var partials = this.scanForPartials(templateSource);
var fetchThemAll = partials.map(function(partialName) { // Ignore templates that include themselves.
var uniquePartials = partials.filter(function(partialName) {
return partialName != templateName;
});
var fetchThemAll = uniquePartials.map(function(partialName) {
return this.cachePartials(partialName); return this.cachePartials(partialName);
}.bind(this)); }.bind(this));