当前位置: 首页>>代码示例>>Java>>正文


Java GroupTemplate.getTemplate方法代码示例

本文整理汇总了Java中org.beetl.core.GroupTemplate.getTemplate方法的典型用法代码示例。如果您正苦于以下问题:Java GroupTemplate.getTemplate方法的具体用法?Java GroupTemplate.getTemplate怎么用?Java GroupTemplate.getTemplate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.beetl.core.GroupTemplate的用法示例。


在下文中一共展示了GroupTemplate.getTemplate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: render

import org.beetl.core.GroupTemplate; //导入方法依赖的package包/类
@Override
public String render(String templatePath, Map<String, Object> data) throws Exception {

    GroupTemplate gt = getGroupTemplate();
    // set template global shared vars
    Map<String, Object> sharedVars = new HashMap<>();
    sharedVars.put("REQUEST", HttpContext.request());
    Session session = HttpContext.request().session();
    sharedVars.put("SESSION", session != null ? session.attributes() : new HashMap<String, Object>());
    gt.setSharedVars(sharedVars);

    Template template = gt.getTemplate(templatePath);
    template.binding(data);

    return template.render();
}
 
开发者ID:thundernet8,项目名称:Razor,代码行数:17,代码来源:BeetlTemplateEngine.java

示例2: main

import org.beetl.core.GroupTemplate; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {

		String home = System.getProperty("user.dir") + File.separator
				+ "template" + File.separator;
		Configuration cf = Configuration.defaultConfiguration();
		cf.setStatementStart("<!--:");
		cf.setStatementEnd("-->");
		FileResourceLoader rs = new FileResourceLoader(home, cf.getCharset());
		GroupTemplate gt = new GroupTemplate(rs, cf);

		List<StockModel> list = StockModel.dummyItems();

		Template t = gt.getTemplate("/helloworld.html");
		t.binding("items", list);
		StringWriter sw = new StringWriter();
		t.renderTo(sw);
		System.out.println(sw.toString());

		// 第二次
		t = gt.getTemplate("/helloworld.html");
		t.binding("items", list);
		sw = new StringWriter();
		t.renderTo(sw);
		System.out.println(sw.toString());

	}
 
开发者ID:javamonkey,项目名称:beetl2.0,代码行数:27,代码来源:GroupTemplateTest.java

示例3: main

import org.beetl.core.GroupTemplate; //导入方法依赖的package包/类
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);


}
 
开发者ID:javamonkey,项目名称:beetl2.0,代码行数:18,代码来源:SharedVars.java

示例4: main

import org.beetl.core.GroupTemplate; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {

		String home = System.getProperty("user.dir") + File.separator
				+ "template" + File.separator;
		Configuration cf = Configuration.defaultConfiguration();
		FileResourceLoader rs = new FileResourceLoader(home, cf.getCharset());
		GroupTemplate gt = new GroupTemplate(rs, cf);
		Template t = gt.getTemplate("/helloworld.html");
		Program p = gt.getProgram("/helloworld.html");
		ProgramMetaData old = p.metaData;
		ProgramMetaData copy = old.copy();
		System.out.println("ok");
	}
 
开发者ID:javamonkey,项目名称:beetl2.0,代码行数:14,代码来源:MetaCopyTest.java

示例5: testSimple

import org.beetl.core.GroupTemplate; //导入方法依赖的package包/类
@Test
public void testSimple() throws Exception
{

	Configuration conf = Configuration.defaultConfiguration();
	CompositeResourceLoader loader = new CompositeResourceLoader();
	String home = System.getProperty("user.dir");
	String path1 = home + "/src/test/resources/template/resourceloader/var1";
	String path2 = home + "/src/test/resources/template/resourceloader/var2";
	FileResourceLoader fileLoader1 = new FileResourceLoader(path1);
	FileResourceLoader fileLoader2 = new FileResourceLoader(path2);
	Map data = getData();
	// 根据id加载
	MapResourceLoader mapLoader = new MapResourceLoader(data);

	loader.addResourceLoader(new StartsWithMatcher("http:").withoutPrefix(), fileLoader2);
	loader.addResourceLoader(new StartsWithMatcher("db:").withoutPrefix(), mapLoader);
	loader.addResourceLoader(new AllowAllMatcher(), fileLoader1);

	GroupTemplate gt = new GroupTemplate(loader, conf);

	Template t = gt.getTemplate("/xxx.html");
	t.binding("a", "hello");
	String result = t.render();
	;
	AssertJUnit.assertEquals("hellohello--file2:hello--db=hello", result);

}
 
开发者ID:javamonkey,项目名称:beetl2.0,代码行数:29,代码来源:CompositeResourceLoaderTest.java

示例6: testSecurity

import org.beetl.core.GroupTemplate; //导入方法依赖的package包/类
@Test
public void testSecurity() throws Exception
{

	StringTemplateResourceLoader resourceLoader = new StringTemplateResourceLoader();
	Configuration cfg = Configuration.defaultConfiguration();
	GroupTemplate gt = new GroupTemplate(resourceLoader, cfg);
	Template t = gt.getTemplate("hello,${@java.lang.System.currentTimeMillis()}");

	String str = t.render();
	AssertJUnit.assertEquals("hello,", str);

}
 
开发者ID:javamonkey,项目名称:beetl2.0,代码行数:14,代码来源:NativeTest.java

示例7: testSimple

import org.beetl.core.GroupTemplate; //导入方法依赖的package包/类
@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);

}
 
开发者ID:javamonkey,项目名称:beetl2.0,代码行数:11,代码来源:SingleDLTest.java

示例8: testSimple

import org.beetl.core.GroupTemplate; //导入方法依赖的package包/类
@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);

}
 
开发者ID:javamonkey,项目名称:beetl2.0,代码行数:11,代码来源:PairDLTest.java

示例9: testPair

import org.beetl.core.GroupTemplate; //导入方法依赖的package包/类
@Test
public void testPair() throws Exception
{

	GroupTemplate newGt = getGt();
	Template t = newGt.getTemplate("/text/pair_template.html");
	String str = t.render();
	AssertJUnit.assertEquals(this.getFileContent("/text/pair_expected.html"), str);

}
 
开发者ID:javamonkey,项目名称:beetl2.0,代码行数:11,代码来源:PairDLTest.java

示例10: main

import org.beetl.core.GroupTemplate; //导入方法依赖的package包/类
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);

}
 
开发者ID:javamonkey,项目名称:beetl2.0,代码行数:13,代码来源:RegisterFunctionByFile.java

示例11: main

import org.beetl.core.GroupTemplate; //导入方法依赖的package包/类
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);

}
 
开发者ID:javamonkey,项目名称:beetl2.0,代码行数:12,代码来源:RegisterFunctionPackage.java

示例12: main

import org.beetl.core.GroupTemplate; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
	
	ClasspathResourceLoader resourceLoader = new ClasspathResourceLoader();		
	URL url = resourceLoader.getClass().getResource("/org/beetl/sample/s01/hello.txt");
	Configuration cfg = Configuration.defaultConfiguration();
	GroupTemplate gt = new GroupTemplate(resourceLoader, cfg);
	Template t = gt.getTemplate("/org/beetl/sample/s01/hello.txt");	
	String str = t.render();
	System.out.println(str);

}
 
开发者ID:javamonkey,项目名称:beetl2.0,代码行数:12,代码来源:ClasspathRL.java

示例13: main

import org.beetl.core.GroupTemplate; //导入方法依赖的package包/类
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);

}
 
开发者ID:javamonkey,项目名称:beetl2.0,代码行数:11,代码来源:HelloBeetl.java

示例14: main

import org.beetl.core.GroupTemplate; //导入方法依赖的package包/类
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("/s01/hello.txt");	
	String str = t.render();		
	System.out.println(str);

}
 
开发者ID:javamonkey,项目名称:beetl2.0,代码行数:12,代码来源:FilePathRL.java

示例15: main

import org.beetl.core.GroupTemplate; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
	
	ClasspathResourceLoader resourceLoader = new ClasspathResourceLoader();		
	Configuration cfg = Configuration.defaultConfiguration();
	GroupTemplate gt = new GroupTemplate(resourceLoader, cfg);
	Template t = gt.getTemplate("/org/beetl/sample/s0125/error1.txt");	
	String str = t.render();
	
	t = gt.getTemplate("/org/beetl/sample/s0125/error2.txt");	
	str = t.render();
	System.out.println(str);

}
 
开发者ID:javamonkey,项目名称:beetl2.0,代码行数:14,代码来源:ErrorTest.java


注:本文中的org.beetl.core.GroupTemplate.getTemplate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。