Search in sources :

Example 21 with GroupTemplate

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());
}
Also used : GroupTemplate(org.beetl.core.GroupTemplate)

Example 22 with GroupTemplate

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 绑定的属性,如&lt;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);
}
Also used : Configuration(org.beetl.core.Configuration) ClasspathResourceLoader(org.beetl.core.resource.ClasspathResourceLoader) GroupTemplate(org.beetl.core.GroupTemplate)

Example 23 with GroupTemplate

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);
}
Also used : GroupTemplate(org.beetl.core.GroupTemplate) GroupTemplate(org.beetl.core.GroupTemplate) Template(org.beetl.core.Template) Test(org.testng.annotations.Test)

Example 24 with GroupTemplate

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);
}
Also used : GroupTemplate(org.beetl.core.GroupTemplate) GroupTemplate(org.beetl.core.GroupTemplate) Template(org.beetl.core.Template) Test(org.testng.annotations.Test)

Example 25 with GroupTemplate

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;
}
Also used : Configuration(org.beetl.core.Configuration) ClasspathResourceLoader(org.beetl.core.resource.ClasspathResourceLoader) IOException(java.io.IOException) GroupTemplate(org.beetl.core.GroupTemplate)

Aggregations

GroupTemplate (org.beetl.core.GroupTemplate)31 Configuration (org.beetl.core.Configuration)22 Template (org.beetl.core.Template)19 ClasspathResourceLoader (org.beetl.core.resource.ClasspathResourceLoader)10 FileResourceLoader (org.beetl.core.resource.FileResourceLoader)7 IOException (java.io.IOException)5 Test (org.testng.annotations.Test)5 Map (java.util.Map)4 Properties (java.util.Properties)4 StringTemplateResourceLoader (org.beetl.core.resource.StringTemplateResourceLoader)4 WebRender (org.beetl.ext.web.WebRender)4 HashMap (java.util.HashMap)3 InputStream (java.io.InputStream)2 List (java.util.List)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 HttpServletResponse (javax.servlet.http.HttpServletResponse)2 WebAppResourceLoader (org.beetl.core.resource.WebAppResourceLoader)2 ToolUtil (com.ikoori.vip.server.core.util.ToolUtil)1 ActionContext (com.opensymphony.xwork2.ActionContext)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1