use of org.febit.wit.util.Props in project hutool by looly.
the class WitEngine method createEngine.
/**
* 创建引擎
*
* @param config 模板配置
* @return {@link Engine}
*/
private static Engine createEngine(TemplateConfig config) {
final Props configProps = Engine.createConfigProps("");
Dict dict = null;
if (null != config) {
dict = Dict.create();
// 自定义编码
dict.set("DEFAULT_ENCODING", config.getCharset());
switch(config.getResourceMode()) {
case CLASSPATH:
configProps.set("pathLoader.root", config.getPath());
configProps.set("routeLoader.defaultLoader", "classpathLoader");
break;
case STRING:
configProps.set("routeLoader.defaultLoader", "stringLoader");
break;
case FILE:
configProps.set("pathLoader.root", config.getPath());
configProps.set("routeLoader.defaultLoader", "fileLoader");
break;
case WEB_ROOT:
final File root = FileUtil.file(FileUtil.getWebRoot(), config.getPath());
configProps.set("pathLoader.root", FileUtil.getAbsolutePath(root));
configProps.set("routeLoader.defaultLoader", "fileLoader");
break;
}
}
return Engine.create(configProps, dict);
}
use of org.febit.wit.util.Props in project hutool by dromara.
the class WitEngine method createEngine.
/**
* 创建引擎
*
* @param config 模板配置
* @return {@link Engine}
*/
private static Engine createEngine(TemplateConfig config) {
final Props configProps = Engine.createConfigProps("");
Dict dict = null;
if (null != config) {
dict = Dict.create();
// 自定义编码
dict.set("DEFAULT_ENCODING", config.getCharset());
switch(config.getResourceMode()) {
case CLASSPATH:
configProps.set("pathLoader.root", config.getPath());
configProps.set("routeLoader.defaultLoader", "classpathLoader");
break;
case STRING:
configProps.set("routeLoader.defaultLoader", "stringLoader");
break;
case FILE:
configProps.set("pathLoader.root", config.getPath());
configProps.set("routeLoader.defaultLoader", "fileLoader");
break;
case WEB_ROOT:
final File root = FileUtil.file(FileUtil.getWebRoot(), config.getPath());
configProps.set("pathLoader.root", FileUtil.getAbsolutePath(root));
configProps.set("routeLoader.defaultLoader", "fileLoader");
break;
}
}
return Engine.create(configProps, dict);
}