Search in sources :

Example 81 with Template

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

the class HtmlTagTest method testJavaTag.

@Test
public void testJavaTag() throws Exception {
    gt.registerTag("simpleTag", SimpleHtmlTag.class);
    Template t = gt.getTemplate("/tag/html5_template.html");
    String str = t.render();
    AssertJUnit.assertEquals(this.getFileContent("/tag/html5_expected.html"), str);
    t = gt.getTemplate("/tag/html5_template.html");
    str = t.render();
    AssertJUnit.assertEquals(this.getFileContent("/tag/html5_expected.html"), str);
}
Also used : GroupTemplate(org.beetl.core.GroupTemplate) Template(org.beetl.core.Template) Test(org.testng.annotations.Test)

Example 82 with Template

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

the class HtmlTagTest method testDilimterHtmlTag.

@Test
public void testDilimterHtmlTag() throws Exception {
    Template t = newGt.getTemplate("/tag/html_dilimeter_template.html");
    this.bind(t, "list", User.getTestUsers());
    String str = t.render();
    AssertJUnit.assertEquals(this.getFileContent("/tag/html_dilimeter_expected.html"), str);
    t = newGt.getTemplate("/tag/html_dilimeter_template.html");
    this.bind(t, "list", User.getTestUsers());
    str = t.render();
    AssertJUnit.assertEquals(this.getFileContent("/tag/html_dilimeter_expected.html"), str);
}
Also used : GroupTemplate(org.beetl.core.GroupTemplate) Template(org.beetl.core.Template) Test(org.testng.annotations.Test)

Example 83 with Template

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

the class HtmlVarBinddingTagTest method testEmptyTag.

@Test
public void testEmptyTag() throws Exception {
    // 将默认搜索路径更改到tag目录下
    gt.registerTag("tagbinding", VarBindingSampleTag.class);
    Template t = gt.getTemplate("/tag/binding/tagbinding_template.html");
    String str = t.render();
    AssertJUnit.assertEquals(this.getFileContent("/tag/binding/tagbinding_expected.html"), str);
    t = gt.getTemplate("/tag/binding/tagbinding_template.html");
    str = t.render();
    AssertJUnit.assertEquals(this.getFileContent("/tag/binding/tagbinding_expected.html"), str);
}
Also used : Template(org.beetl.core.Template) Test(org.testng.annotations.Test)

Example 84 with Template

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

the class HtmlVarBinddingTagTest method testLoopTag.

@Test
public void testLoopTag() throws Exception {
    // 将默认搜索路径更改到tag目录下
    gt.registerTag("tagloopbinding", VarBindingLoopSampleTag.class);
    // todo 会多出一个空行
    Template t = gt.getTemplate("/tag/binding/tagloopbinding_template.html");
    String str = t.render();
    AssertJUnit.assertEquals(this.getFileContent("/tag/binding/tagloopbinding_expected.html"), str);
    t = gt.getTemplate("/tag/binding/tagloopbinding_template.html");
    str = t.render();
    AssertJUnit.assertEquals(this.getFileContent("/tag/binding/tagloopbinding_expected.html"), str);
}
Also used : Template(org.beetl.core.Template) Test(org.testng.annotations.Test)

Example 85 with Template

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

the class LayoutTagTest method testLayoutInclude.

@Test
public void testLayoutInclude() throws Exception {
    User user = User.getTestUser();
    Template t = gt.getTemplate("/tag/layoutinclude_template.html");
    this.bind(t, "user", user);
    String str = t.render();
    AssertJUnit.assertEquals(this.getFileContent("/tag/layoutinclude_expected.html"), str);
    t = gt.getTemplate("/tag/layoutinclude_template.html");
    this.bind(t, "user", user);
    str = t.render();
    AssertJUnit.assertEquals(this.getFileContent("/tag/layoutinclude_expected.html"), str);
}
Also used : User(org.beetl.core.User) Template(org.beetl.core.Template) Test(org.testng.annotations.Test)

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