MDL-84076 core_templates: Avoid manipulation of template context object

This commit is contained in:
Philipp Memmel
2025-01-01 22:04:40 +01:00
parent 8e37adaddf
commit a30c61ba2c
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
@@ -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),
);