# 自定义脚本语言1.0.0+

/**
 * 自定义脚本语言
 */
@Component  //注入到Spring容器中
public class TestLanguage implements LanguageProvider {

	@Override
	public boolean support(String languageName) {
		return "test".equalsIgnoreCase(languageName);
	}

	@Override
	public Object execute(String languageName, String script, Map<String, Object> context) throws Exception {
		return "hello " + context.get("name");
	}

}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

在脚本中使用

var name = "test variable"
var func = ```test
 // 任意代码
```;
return func();
//返回结果:hello test variable
1
2
3
4
5
6
上次更新: 6/27/2021, 12:21:08 PM