Search in sources :

Example 36 with Template

use of org.beetl.core.Template in project beetl2.0 by javamonkey.

the class JsonTest method testData.

@Test
public void testData() throws Exception {
    Template t = gt.getTemplate("/exp/json/data_template.html");
    String str = t.render();
    AssertJUnit.assertEquals(this.getFileContent("/exp/json/data_expected.html"), str);
    t = gt.getTemplate("/exp/json/data_template.html");
    str = t.render();
    AssertJUnit.assertEquals(this.getFileContent("/exp/json/data_expected.html"), str);
}
Also used : Template(org.beetl.core.Template) Test(org.testng.annotations.Test)

Example 37 with Template

use of org.beetl.core.Template in project beetl2.0 by javamonkey.

the class FormatterTest method testCore.

@Test
public void testCore() throws Exception {
    gt.registerFormat("date.short", new ShortDateFormatter());
    Map map = new HashMap();
    map.put("a", 1.12);
    Template t = gt.getTemplate("/formatter/formatter_template.html");
    t.binding(map);
    String str = t.render();
    AssertJUnit.assertEquals(this.getFileContent("/formatter/formatter_expected.html"), str);
    t = gt.getTemplate("/formatter/formatter_template.html");
    t.binding(map);
    str = t.render();
    AssertJUnit.assertEquals(this.getFileContent("/formatter/formatter_expected.html"), str);
}
Also used : HashMap(java.util.HashMap) Map(java.util.Map) HashMap(java.util.HashMap) Template(org.beetl.core.Template) Test(org.testng.annotations.Test)

Example 38 with Template

use of org.beetl.core.Template in project beetl2.0 by javamonkey.

the class FileFunctionTest method testFunctionDilimter.

@Test
public void testFunctionDilimter() throws Exception {
    // 测试html 方法和注解允许使用特殊符号
    Template t = newGt.getTemplate("/function/dilimter_template.html");
    String str = t.render();
    AssertJUnit.assertEquals(this.getFileContent("/function/dilimter_expected.html"), str);
    t = newGt.getTemplate("/function/dilimter_template.html");
    str = t.render();
    AssertJUnit.assertEquals(this.getFileContent("/function/dilimter_expected.html"), str);
}
Also used : GroupTemplate(org.beetl.core.GroupTemplate) Template(org.beetl.core.Template) Test(org.testng.annotations.Test)

Example 39 with Template

use of org.beetl.core.Template in project beetl2.0 by javamonkey.

the class FunctionTest method testSafeOutput.

public void testSafeOutput() throws Exception {
    gt.registerFunction("nullFunction", new NullFunction());
    Template t = gt.getTemplate("/function/null_template.html");
    String str = t.render();
    AssertJUnit.assertEquals(this.getFileContent("/function/null_expected.html"), str);
    t = gt.getTemplate("/function/null_template.html");
    str = t.render();
    AssertJUnit.assertEquals(this.getFileContent("/function/null_expected.html"), str);
}
Also used : Template(org.beetl.core.Template)

Example 40 with Template

use of org.beetl.core.Template in project beetl2.0 by javamonkey.

the class FunctionTest method testToolKit.

public void testToolKit() throws Exception {
    gt.registerFunction("str2Json", new Str2Json());
    Template t = gt.getTemplate("/function/tojson_template.html");
    String str = t.render();
    AssertJUnit.assertEquals(this.getFileContent("/function/tojson_expected.html"), str);
    t = gt.getTemplate("/function/tojson_template.html");
    str = t.render();
    AssertJUnit.assertEquals(this.getFileContent("/function/tojson_expected.html"), str);
}
Also used : Template(org.beetl.core.Template)

Aggregations

Template (org.beetl.core.Template)122 Test (org.testng.annotations.Test)96 GroupTemplate (org.beetl.core.GroupTemplate)41 Map (java.util.Map)15 User (org.beetl.core.User)14 HashMap (java.util.HashMap)13 Configuration (org.beetl.core.Configuration)13 FileResourceLoader (org.beetl.core.resource.FileResourceLoader)6 StringTemplateResourceLoader (org.beetl.core.resource.StringTemplateResourceLoader)6 Context (org.beetl.core.Context)5 JSONObject (com.alibaba.fastjson.JSONObject)4 List (java.util.List)4 ClasspathResourceLoader (org.beetl.core.resource.ClasspathResourceLoader)4 VirtualAttributeEval (org.beetl.core.VirtualAttributeEval)3 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 HttpServletResponse (javax.servlet.http.HttpServletResponse)2 BodyContent (org.beetl.core.BodyContent)2 BeetlException (org.beetl.core.exception.BeetlException)2 WebRender (org.beetl.ext.web.WebRender)2 JsonNode (com.fasterxml.jackson.databind.JsonNode)1