MDL-84076 core_templates: Avoid manipulation of template context object
This commit is contained in:
+1
-1
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),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user