use of org.beetl.core.GroupTemplate in project vip by guangdada.
the class ShiroExt method main.
public static void main(String[] args) {
GroupTemplate gt = new GroupTemplate();
gt.registerFunctionPackage("shiro", new ShiroExt());
}
use of org.beetl.core.GroupTemplate in project docx4j-template by vindell.
the class WordprocessingMLBeetlTemplate method getInternalEngine.
protected GroupTemplate getInternalEngine() throws IOException {
ClasspathResourceLoader loader = new ClasspathResourceLoader();
// 加载默认参数
Configuration cfg = Configuration.defaultConfiguration();
// 模板字符集
cfg.setCharset(Docx4jProperties.getProperty("docx4j.beetl.charset", Docx4jConstants.DEFAULT_CHARSETNAME));
// 模板占位起始符号
cfg.setPlaceholderStart(Docx4jProperties.getProperty("docx4j.beetl.placeholderStart", "${"));
// 模板占位结束符号
cfg.setPlaceholderEnd(Docx4jProperties.getProperty("docx4j.beetl.placeholderEnd", "<%"));
// 控制语句起始符号
cfg.setStatementStart(Docx4jProperties.getProperty("docx4j.beetl.statementStart", "%>"));
// 控制语句结束符号
cfg.setStatementEnd(Docx4jProperties.getProperty("docx4j.beetl.statementEnd", "}"));
// 是否允许html tag,在web编程中,有可能用到html tag,最好允许
cfg.setHtmlTagSupport(Docx4jProperties.getProperty("docx4j.beetl.htmlTagSupport", false));
// html tag 标示符号
cfg.setHtmlTagFlag(Docx4jProperties.getProperty("docx4j.beetl.htmlTagFlag", "#"));
// html 绑定的属性,如<aa var="customer">
cfg.setHtmlTagBindingAttribute(Docx4jProperties.getProperty("docx4j.beetl.htmlTagBindingAttribute", "var"));
// 是否允许直接调用class
cfg.setNativeCall(Docx4jProperties.getProperty("docx4j.beetl.nativeCall", false));
// 输出模式,默认是字符集输出,改成byte输出提高性能
cfg.setDirectByteOutput(Docx4jProperties.getProperty("docx4j.beetl.directByteOutput", true));
// 严格mvc应用,只有变态的的人才打开此选项
cfg.setStrict(Docx4jProperties.getProperty("docx4j.beetl.strict", false));
// 是否忽略客户端的网络异常
cfg.setIgnoreClientIOError(Docx4jProperties.getProperty("docx4j.beetl.ignoreClientIOError", true));
// 错误处理类
cfg.setErrorHandlerClass(Docx4jProperties.getProperty("docx4j.beetl.errorHandlerClass", "org.beetl.core.ConsoleErrorHandler"));
// 资源参数
Map<String, String> resourceMap = cfg.getResourceMap();
// classpath 跟路径
resourceMap.put("root", Docx4jProperties.getProperty("docx4j.beetl.resource.root", "/"));
// 是否检测文件变化
resourceMap.put("autoCheck", Docx4jProperties.getProperty("docx4j.beetl.resource.autoCheck", "true"));
// 自定义脚本方法文件位置
resourceMap.put("functionRoot", Docx4jProperties.getProperty("docx4j.beetl.resource.functionRoot", "functions"));
// 自定义脚本方法文件的后缀
resourceMap.put("functionSuffix", Docx4jProperties.getProperty("docx4j.beetl.resource.functionSuffix", "html"));
// 自定义标签文件位置
resourceMap.put("tagRoot", Docx4jProperties.getProperty("docx4j.beetl.resource.tagRoot", "htmltag"));
// 自定义标签文件后缀
resourceMap.put("tagSuffix", Docx4jProperties.getProperty("docx4j.beetl.resource.tagSuffix", "tag"));
cfg.setResourceMap(resourceMap);
return new GroupTemplate(loader, cfg);
}
use of org.beetl.core.GroupTemplate in project beetl2.0 by javamonkey.
the class PairDLTest method testSimple.
@Test
public void testSimple() throws Exception {
GroupTemplate newGt = getGt();
Template t = newGt.getTemplate("/text/simple_pair_template.html");
String str = t.render();
AssertJUnit.assertEquals(this.getFileContent("/text/simple_pair_expected.html"), str);
}
use of org.beetl.core.GroupTemplate in project beetl2.0 by javamonkey.
the class SingleDLTest method testSimple.
@Test
public void testSimple() throws Exception {
GroupTemplate newGt = getGt();
Template t = newGt.getTemplate("/text/single_template.html");
String str = t.render();
AssertJUnit.assertEquals(this.getFileContent("/text/single_expected.html"), str);
}
use of org.beetl.core.GroupTemplate in project beetl2.0 by javamonkey.
the class SingleDLTest method getGt.
public GroupTemplate getGt() {
ClasspathResourceLoader rs = new ClasspathResourceLoader("/template");
Configuration cfg;
try {
cfg = Configuration.defaultConfiguration();
} catch (IOException e) {
throw new RuntimeException(e);
}
cfg.setStatementEnd(null);
cfg.setStatementStart("@");
GroupTemplate gt = new GroupTemplate(rs, cfg);
return gt;
}
Aggregations