use of org.beetl.core.Template in project beetl2.0 by javamonkey.
the class NativeTest method testArray.
@Test
public void testArray() throws Exception {
NativeTest test = new NativeTest();
Template t = gt.getTemplate("/nat/nat_array_template.html");
this.bind(t, "test", test);
String str = t.render();
AssertJUnit.assertEquals(this.getFileContent("/nat/nat_array_expected.html"), str);
t = gt.getTemplate("/nat/nat_array_template.html");
this.bind(t, "test", test);
str = t.render();
AssertJUnit.assertEquals(this.getFileContent("/nat/nat_array_expected.html"), str);
}
use of org.beetl.core.Template in project beetl2.0 by javamonkey.
the class NativeTest method testAttr.
@Test
public void testAttr() throws Exception {
NativeTest test = new NativeTest();
Template t = gt.getTemplate("/nat/nat_attr_template.html");
this.bind(t, "test", test);
String str = t.render();
AssertJUnit.assertEquals(this.getFileContent("/nat/nat_attr_expected.html"), str);
t = gt.getTemplate("/nat/nat_attr_template.html");
this.bind(t, "test", test);
str = t.render();
AssertJUnit.assertEquals(this.getFileContent("/nat/nat_attr_expected.html"), str);
}
use of org.beetl.core.Template in project beetl2.0 by javamonkey.
the class HTMLTagSupportWrapper method callHtmlTag.
protected void callHtmlTag(String path) {
Template t = null;
t = gt.getHtmlFunctionOrTagTemplate(path, this.ctx.getResourceId());
t.binding(ctx.globalVar);
t.dynamic(ctx.objectKeys);
if (args.length == 2) {
Map<String, Object> map = (Map<String, Object>) args[1];
for (Entry<String, Object> entry : map.entrySet()) {
t.binding(entry.getKey(), entry.getValue());
}
}
BodyContent bodyContent = super.getBodyContent();
t.binding("tagBody", bodyContent);
t.renderTo(ctx.byteWriter);
}
use of org.beetl.core.Template in project hello-world by haoziapple.
the class BasicUse method main.
public static void main(String[] args) throws Exception {
StringTemplateResourceLoader resourceLoader = new StringTemplateResourceLoader();
Configuration cfg = Configuration.defaultConfiguration();
GroupTemplate gt = new GroupTemplate(resourceLoader, cfg);
Template t = gt.getTemplate("hello,${name}");
t.binding("name", "beetl");
String str = t.render();
System.out.println(str);
}
use of org.beetl.core.Template in project vip by guangdada.
the class GunsTemplateEngine method generateFile.
public void generateFile(String template, String filePath) {
Template pageTemplate = groupTemplate.getTemplate(template);
configTemplate(pageTemplate);
// filePath = filePath.replaceAll("\\\\",File.separator);
File file = new File(filePath);
File parentFile = file.getParentFile();
if (!parentFile.exists()) {
parentFile.mkdirs();
}
try {
pageTemplate.renderTo(new FileOutputStream(file));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
Aggregations