@@ -37,6 +37,13 @@ func (x *Node) fmBridge(name string) *bridgeName {
37
37
}
38
38
39
39
func (node * Node ) fmScript (args ... any ) (any , error ) {
40
+ var js_is_es6 bool
41
+ if flag , ok := node .pragma ["es6" ]; ok {
42
+ if b , err := strconv .ParseBool (flag ); err == nil {
43
+ js_is_es6 = b
44
+ }
45
+ }
46
+
40
47
if len (args ) == 1 {
41
48
text , ok := args [0 ].(string )
42
49
if ! ok {
@@ -53,7 +60,7 @@ func (node *Node) fmScript(args ...any) (any, error) {
53
60
}
54
61
case string :
55
62
switch name {
56
- case "js" , "javascript" :
63
+ case "js" , "javascript" , "es6" :
57
64
initCode , mainCode := "" , ""
58
65
if len (args ) == 2 { // SCRIPT("js", "main")
59
66
if str , ok := args [1 ].(string ); ! ok {
@@ -75,7 +82,11 @@ func (node *Node) fmScript(args ...any) (any, error) {
75
82
} else {
76
83
goto syntaxErr
77
84
}
78
- return node .fmScriptOtto (initCode , mainCode )
85
+ if name == "es6" || (js_is_es6 && name == "js" ) {
86
+ return node .fmScriptGoja (initCode , mainCode )
87
+ } else {
88
+ return node .fmScriptOtto (initCode , mainCode )
89
+ }
79
90
case "tengo" :
80
91
if text , ok := args [1 ].(string ); ! ok {
81
92
goto syntaxErr
0 commit comments