File tree 1 file changed +8
-4
lines changed
1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -862,18 +862,22 @@ defaultMethods.var.compile = function (data, buildState) {
862
862
const pieces = splitPath ( key )
863
863
const [ top ] = pieces
864
864
buildState . varTop . add ( top )
865
+
866
+ if ( ! buildState . engine . allowFunctions ) buildState . methods . preventFunctions = a => typeof a === 'function' ? null : a
867
+ else buildState . methods . preventFunctions = a => a
868
+
865
869
// support older versions of node
866
870
if ( ! chainingSupported ) {
867
- return `(((a,b) => (typeof a === 'undefined' || a === null) ? b : a)(${ pieces . reduce (
871
+ return `(methods.preventFunctions( ((a,b) => (typeof a === 'undefined' || a === null) ? b : a)(${ pieces . reduce (
868
872
( text , i ) => {
869
873
return `(${ text } ||0)[${ JSON . stringify ( i ) } ]`
870
874
} ,
871
875
'(context||0)'
872
- ) } , ${ buildString ( defaultValue , buildState ) } ))`
876
+ ) } , ${ buildString ( defaultValue , buildState ) } ))) `
873
877
}
874
- return `(context${ pieces
878
+ return `(methods.preventFunctions( context${ pieces
875
879
. map ( ( i ) => `?.[${ JSON . stringify ( i ) } ]` )
876
- . join ( '' ) } ?? ${ buildString ( defaultValue , buildState ) } )`
880
+ . join ( '' ) } ?? ${ buildString ( defaultValue , buildState ) } )) `
877
881
}
878
882
buildState . useContext = true
879
883
return false
You can’t perform that action at this time.
0 commit comments