Optimise cloneDeep usage in string templates

This commit is contained in:
Andrew Kingston 2024-03-13 12:11:09 +00:00
parent 886929b8bc
commit 64855bbdf0
1 changed files with 2 additions and 1 deletions

View File

@ -54,8 +54,9 @@ module.exports.processJS = (handlebars, context) => {
// Our $ context function gets a value from context. // Our $ context function gets a value from context.
// We clone the context to avoid mutation in the binding affecting real // We clone the context to avoid mutation in the binding affecting real
// app context. // app context.
const clonedContext = cloneDeep(context)
const sandboxContext = { const sandboxContext = {
$: path => getContextValue(path, cloneDeep(context)), $: path => getContextValue(path, clonedContext),
helpers: getJsHelperList(), helpers: getJsHelperList(),
// Proxy to evaluate snippets when running in the browser // Proxy to evaluate snippets when running in the browser