提交 9c05c7eb 编写于 作者: Mosher's avatar Mosher

add:新增jsonParse工具助手

上级 a5680144
......@@ -2,6 +2,7 @@ package cn.ibizlab.codegen.templating.handlebars;
import cn.ibizlab.codegen.utils.Inflector;
import cn.ibizlab.codegen.utils.StringAdvUtils;
import com.alibaba.fastjson.JSONObject;
import com.github.jknack.handlebars.Helper;
import com.github.jknack.handlebars.Options;
import com.github.jknack.handlebars.TagType;
......@@ -117,6 +118,12 @@ public enum StringHelpers implements Helper<Object> {
protected CharSequence safeApply(final Object value, final Options options) {
return Inflector.getInstance().pluralize(StringAdvUtils.camelcase(value.toString()).toLowerCase());
}
},
jsonParse {
@Override
protected CharSequence safeApply(Object context, Options options) throws IOException {
return options.fn(JSONObject.parseObject(context.toString()));
}
};
......@@ -137,7 +144,7 @@ public enum StringHelpers implements Helper<Object> {
* @param options The options object.
* @return A string result.
*/
protected abstract CharSequence safeApply(Object context, Options options);
protected abstract CharSequence safeApply(Object context, Options options) throws IOException;
}
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册