use of org.beetl.core.Template in project beetl2.0 by javamonkey.
the class SharedVars method main.
public static void main(String[] args) throws Exception {
ClasspathResourceLoader resourceLoader = new ClasspathResourceLoader();
Configuration cfg = Configuration.defaultConfiguration();
GroupTemplate gt = new GroupTemplate(resourceLoader, cfg);
Map<String, Object> shared = new HashMap<String, Object>();
shared.put("name", "beetl");
gt.setSharedVars(shared);
Template t = gt.getTemplate("/org/beetl/sample/s0208/t1.txt");
String str = t.render();
System.out.println(str);
t = gt.getTemplate("/org/beetl/sample/s0208/t2.txt");
str = t.render();
System.out.println(str);
}
use of org.beetl.core.Template in project beetl2.0 by javamonkey.
the class RegisterFunctionByFile method main.
public static void main(String[] args) throws Exception {
String root = System.getProperty("user.dir") + File.separator + "template";
FileResourceLoader resourceLoader = new FileResourceLoader(root, "utf-8");
Configuration cfg = Configuration.defaultConfiguration();
GroupTemplate gt = new GroupTemplate(resourceLoader, cfg);
gt.registerFunctionPackage("t", new FunctionPackage());
Template t = gt.getTemplate("/s32/functionPackage.html");
String str = t.render();
System.out.println(str);
}
use of org.beetl.core.Template in project beetl2.0 by javamonkey.
the class RegisterFunctionPackage method main.
public static void main(String[] args) throws Exception {
String root = System.getProperty("user.dir") + File.separator + "template";
FileResourceLoader resourceLoader = new FileResourceLoader(root, "utf-8");
Configuration cfg = Configuration.defaultConfiguration();
GroupTemplate gt = new GroupTemplate(resourceLoader, cfg);
Template t = gt.getTemplate("/s32/pagefunction.html");
String str = t.render();
System.out.println(str);
}
use of org.beetl.core.Template in project beetl2.0 by javamonkey.
the class ResourceLoaderTest method testRemove.
@Test
public void testRemove() throws Exception {
Map data = getData();
MapResourceLoader strLoader = new MapResourceLoader(data);
Template t = gt.getTemplate("db:2", strLoader);
String result = t.render();
gt.removeTemplate("db:2");
AssertJUnit.assertEquals(false, gt.hasTemplate("db:2"));
}
use of org.beetl.core.Template in project beetl2.0 by javamonkey.
the class ResourceLoaderTest method testExtraLoader.
@Test
public void testExtraLoader() throws Exception {
Map data = getData();
MapResourceLoader strLoader = new MapResourceLoader(data);
Template t = gt.getTemplate("db:1", strLoader);
t.binding("a", "abc");
String result = t.render();
AssertJUnit.assertEquals("abc", result);
}
Aggregations