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


Java Template.render方法代码示例

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


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

示例1: render

import org.beetl.core.Template; //导入方法依赖的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: testIncludeRel

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

	User user = User.getTestUser();

	Template t = gt.getTemplate("/tag/main_include_template.html");
	this.bind(t, "user", user);
	String str = t.render();
	AssertJUnit.assertEquals(this.getFileContent("/tag/main_include_expected.html"), str);

	t = gt.getTemplate("/tag/main_include_template.html");
	this.bind(t, "user", user);
	str = t.render();
	AssertJUnit.assertEquals(this.getFileContent("/tag/main_include_expected.html"), str);

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

示例3: testCore

import org.beetl.core.Template; //导入方法依赖的package包/类
@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);
}
 
开发者ID:javamonkey,项目名称:beetl2.0,代码行数:19,代码来源:FormatterTest.java

示例4: testMul

import org.beetl.core.Template; //导入方法依赖的package包/类
@Test
public void testMul() throws Exception
{
	Template t = gt.getTemplate("/exp/bignumber/number_mul_template.html");
	this.bind(t, "d1", d1, "d2", d2);
	String str = t.render();

	AssertJUnit.assertEquals(this.getFileContent("/exp/bignumber/number_mul_expected.html"), str);

	t = gt.getTemplate("/exp/bignumber/number_mul_template.html");
	this.bind(t, "d1", d1, "d2", d2);
	str = t.render();

	AssertJUnit.assertEquals(this.getFileContent("/exp/bignumber/number_mul_expected.html"), str);

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

示例5: testCompare

import org.beetl.core.Template; //导入方法依赖的package包/类
@Test
public void testCompare() throws Exception
{
	Template t = gt.getTemplate("/exp/general_compare_template.html");
	this.bind(t, "d1", d1, "d2", d2);
	String str = t.render();

	AssertJUnit.assertEquals(this.getFileContent("/exp/general_compare_expected.html"), str);

	t = gt.getTemplate("/exp/general_compare_template.html");
	this.bind(t, "d1", d1, "d2", d2);
	str = t.render();

	AssertJUnit.assertEquals(this.getFileContent("/exp/general_compare_expected.html"), str);

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

示例6: process

import org.beetl.core.Template; //导入方法依赖的package包/类
@Override
public WordprocessingMLPackage process(Map<String, Object> variables) throws Exception {
	//使用Beetl模板引擎渲染模板
	Template template = getEngine().getTemplate(templateKey);
	template.binding(variables);
	//获取模板渲染后的结果
	String html = template.render();
	//使用HtmlTemplate进行渲染
	return new WordprocessingMLHtmlTemplate(html , altChunk).process(variables);
}
 
开发者ID:vindell,项目名称:docx4j-template,代码行数:11,代码来源:WordprocessingMLBeetlTemplate.java

示例7: testAll

import org.beetl.core.Template; //导入方法依赖的package包/类
@Test
public void testAll() throws Exception
{
	NativeTest test = new NativeTest();
	Template t = gt.getTemplate("/nat/all_template.html");
	this.bind(t, "test", test);
	String str = t.render();
	AssertJUnit.assertEquals(this.getFileContent("/nat/all_expected.html"), str);

	t = gt.getTemplate("/nat/all_template.html");
	this.bind(t, "test", test);
	str = t.render();
	AssertJUnit.assertEquals(this.getFileContent("/nat/all_expected.html"), str);
}
 
开发者ID:javamonkey,项目名称:beetl2.0,代码行数:15,代码来源:NativeTest.java

示例8: testPrivateMethodCall

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

	Template t = gt.getTemplate("/nat/nat_private_method_template.html");
	this.bind(t, "test", Request.getRequest());
	String str = t.render();
	AssertJUnit.assertEquals(this.getFileContent("/nat/nat_private_method_expected.html"), str);

	t = gt.getTemplate("/nat/nat_private_method_template.html");
	this.bind(t, "test", Request.getRequest());
	str = t.render();
	AssertJUnit.assertEquals(this.getFileContent("/nat/nat_private_method_expected.html"), str);
}
 
开发者ID:javamonkey,项目名称:beetl2.0,代码行数:15,代码来源:NativeTest.java

示例9: main

import org.beetl.core.Template; //导入方法依赖的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

示例10: testGeneral

import org.beetl.core.Template; //导入方法依赖的package包/类
@Test
public void testGeneral() throws Exception
{
	Template t = gt.getTemplate("/control/generalFor/general_template.html");

	String str = t.render();
	AssertJUnit.assertEquals(this.getFileContent("/control/generalFor/general_expected.html"), str);

	t = gt.getTemplate("/control/generalFor/general_template.html");
	//this.bind(t, "dataList", data);
	str = t.render();
	AssertJUnit.assertEquals(this.getFileContent("/control/generalFor/general_expected.html"), str);

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

示例11: testBreak

import org.beetl.core.Template; //导入方法依赖的package包/类
@Test
public void testBreak() throws Exception
{
	Template t = gt.getTemplate("/control/generalFor/general_break_template.html");

	String str = t.render();
	AssertJUnit.assertEquals(this.getFileContent("/control/generalFor/general_break_expected.html"), str);

	//		t = gt.getTemplate("/control/generalFor/general_break_template.html");
	//		//this.bind(t, "dataList", data);
	//		str = t.render();
	//		AssertJUnit.assertEquals(this.getFileContent("/control/generalFor/general_break_expected.html"), str);

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

示例12: testBreak

import org.beetl.core.Template; //导入方法依赖的package包/类
@Test
public void testBreak() throws Exception
{
	Template t = gt.getTemplate("/control/go/break_template.html");
	this.bind(t, "dataList", data);
	String str = t.render();
	AssertJUnit.assertEquals(this.getFileContent("/control/go/break_expected.html"), str);

	t = gt.getTemplate("/control/go/break_template.html");
	this.bind(t, "dataList", data);
	str = t.render();
	AssertJUnit.assertEquals(this.getFileContent("/control/go/break_expected.html"), str);

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

示例13: testSafeOutput

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

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

示例14: testObjectReturn

import org.beetl.core.Template; //导入方法依赖的package包/类
@Test
public void testObjectReturn() throws Exception
{
	NativeTest test = new NativeTest();
	Template t = gt.getTemplate("/nat/object_template.html");
	this.bind(t, "test", test);
	String str = t.render();
	AssertJUnit.assertEquals(this.getFileContent("/nat/object_expected.html"), str);

	t = gt.getTemplate("/nat/object_template.html");
	this.bind(t, "test", test);
	str = t.render();
	AssertJUnit.assertEquals(this.getFileContent("/nat/object_expected.html"), str);
}
 
开发者ID:javamonkey,项目名称:beetl2.0,代码行数:15,代码来源:NativeTest.java

示例15: testMethodParameter

import org.beetl.core.Template; //导入方法依赖的package包/类
@Test
public void testMethodParameter() throws Exception
{
	NativeTest test = new NativeTest();
	Template t = gt.getTemplate("/nat/nat_method2_template.html");
	this.bind(t, "test", test);
	String str = t.render();
	AssertJUnit.assertEquals(this.getFileContent("/nat/nat_method2_expected.html"), str);

	t = gt.getTemplate("/nat/nat_method2_template.html");
	this.bind(t, "test", test);
	str = t.render();
	AssertJUnit.assertEquals(this.getFileContent("/nat/nat_method2_expected.html"), str);
}
 
开发者ID:javamonkey,项目名称:beetl2.0,代码行数:15,代码来源:NativeTest.java


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