MDL-84076 core_templates: Avoid manipulation of template context object

This commit is contained in:
Philipp Memmel
2025-09-05 09:59:06 +02:00
parent 4e5151db5f
commit cbb7382c86
3 changed files with 6 additions and 4 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+4 -2
View File
@@ -571,12 +571,14 @@ export default class Renderer {
Renderer.getLoader().getTemplate(iconTemplate, themeName),
]);
this.addHelpers(context, themeName);
// Clone context object to avoid manipulating the original context object.
const templateContext = {...context};
this.addHelpers(templateContext, themeName);
// Render the template.
const renderedContent = await mustache.render(
templateSource,
context,
templateContext,
// Note: The third parameter is a function that will be called to process partials.
(partialName) => Renderer.getLoader().partialHelper(partialName, themeName),
);