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


Java Template.binding方法代码示例

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


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

示例1: generateMappingModel

import org.beetl.core.Template; //导入方法依赖的package包/类
public void generateMappingModel(Object projectId, String templatePath) {
  if ( StrKit.isBlank(templatePath) ) templatePath = MAVEN_BASE + "gen/config/4jfinalmappingmodel.btl";
  Template t_pojo = gt.getTemplate(templatePath);
  List<Record> list = Db.find("select a.*, b.name primary_name, b.java_type, c.package, c.module_name from w_db_model a, w_db_model_item b, w_generate c where a.id = b.w_model_id and c.w_model_id = a.id and b.is_primary = 1 and a.project_id = ?", projectId);
  t_pojo.binding("models", list);
  File file = getConfigGenerateFile(
          File.separator + "org" +
                  File.separator + "hacker" +
                  File.separator + "core" +
                  File.separator + "config",
          "MappingModel.java");
  System.out.println(file.getAbsolutePath());
  try {
    FileKit.write(t_pojo.render(), file);
  } catch ( FileNotFoundException | BeetlException e ) {
    e.printStackTrace();
  }
  System.out.println("############getGenerateConfig success############");
}
 
开发者ID:slashchenxiaojun,项目名称:wall.e,代码行数:20,代码来源:TempletGenerate.java

示例2: callHtmlTag

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

示例3: generateMappingRoute

import org.beetl.core.Template; //导入方法依赖的package包/类
public void generateMappingRoute(Object projectId, String templatePath) {
  if ( StrKit.isBlank(templatePath) ) templatePath = MAVEN_BASE + "gen/config/4jfinalmappingroute.btl";
  Template t_pojo = gt.getTemplate(templatePath);
  List<Record> list = Db.find("select a.*, b.name primary_name, b.java_type, c.package, c.module_name from w_db_model a, w_db_model_item b, w_generate c where a.id = b.w_model_id and c.w_model_id = a.id and b.is_primary = 1 and a.project_id = ?", projectId);
  t_pojo.binding("models", list);
  File file = getConfigGenerateFile(
          File.separator + "org" +
                  File.separator + "hacker" +
                  File.separator + "core" +
                  File.separator + "config",
          "MappingRoute.java");
  System.out.println(file.getAbsolutePath());
  try {
    FileKit.write(t_pojo.render(), file);
  } catch ( FileNotFoundException | BeetlException e ) {
    e.printStackTrace();
  }
  System.out.println("############getGenerateConfig success############");
}
 
开发者ID:slashchenxiaojun,项目名称:wall.e,代码行数:20,代码来源:TempletGenerate.java

示例4: test_controller

import org.beetl.core.Template; //导入方法依赖的package包/类
public void test_controller() {
  int id = 3;
  gt.registerFunction("firstCharToLowerCase", new FirstCharToLowerCase());
   DbModel model = DbModel.dao.findById(id);
   List<DbModelItem> columns = DbModelItem.dao.find("select * from w_db_model_item where w_model_id = ? order by serial", id);
   Generate generate = Generate.dao.findFirst("select * from w_generate where w_model_id = ?", id);

   // 查找出跟model有关的list
   List<Record> master = Db.find("select b.class_name, a.*, c.package, c.module_name from w_db_model_mapping a, w_db_model b, w_generate c where a.master_id = b.id and a.slaves_id = ? and a.master_id = c.w_model_id", id);
   // 查找出跟model相关的从表
   List<Record> slaves = Db.find("SELECT a.class_name, b.*, c.package, c.module_name FROM w_db_model a, w_db_model_mapping b, w_generate c WHERE a.id = b.slaves_id AND b.master_id = ? and c.w_model_id = b.slaves_id", id);

   Template t = gt.getTemplate("gen/web/4Jfinalcontroller.btl");
   t.binding("model", model);
   t.binding("columns", columns);

   t.binding("generate", generate);
   t.binding("master", master);
   t.binding("slaves", slaves);
   // 是否使用驼峰命名
   t.binding("camelName", true);
   System.out.println(t.render());
}
 
开发者ID:slashchenxiaojun,项目名称:wall.e,代码行数:24,代码来源:TempletGenerateTest.java

示例5: test_service

import org.beetl.core.Template; //导入方法依赖的package包/类
public void test_service() {
  int id = 3;
  gt.registerFunction("firstCharToLowerCase", new FirstCharToLowerCase());
  DbModel model = DbModel.dao.findById(id);
  List<DbModelItem> columns = DbModelItem.dao.find("select * from w_db_model_item where w_model_id = ? order by serial", id);
  Generate generate = Generate.dao.findFirst("select * from w_generate where w_model_id = ?", id);

  // 查找出跟model有关的list
  List<Record> master = Db.find("select b.class_name, a.*, c.package, c.module_name from w_db_model_mapping a, w_db_model b, w_generate c where a.master_id = b.id and a.slaves_id = ? and a.master_id = c.w_model_id", id);
  // 查找出跟model相关的从表
  List<Record> slaves = Db.find("SELECT a.class_name, b.*, c.package, c.module_name FROM w_db_model a, w_db_model_mapping b, w_generate c WHERE a.id = b.slaves_id AND b.master_id = ? and c.w_model_id = b.slaves_id", id);

  Template t = gt.getTemplate("gen/web/4curd&webservice.btl");
  t.binding("model", model);
  t.binding("columns", columns);

  t.binding("generate", generate);
  t.binding("master", master);
  t.binding("slaves", slaves);
  // 是否使用驼峰命名
  t.binding("camelName", true);
  System.out.println(t.render());
}
 
开发者ID:slashchenxiaojun,项目名称:wall.e,代码行数:24,代码来源:TempletGenerateTest.java

示例6: test_sqlmd

import org.beetl.core.Template; //导入方法依赖的package包/类
public void test_sqlmd() {
  int id = 3;
  gt.registerFunction("firstCharToLowerCase", new FirstCharToLowerCase());
  DbModel model = DbModel.dao.findById(id);
  List<DbModelItem> columns = DbModelItem.dao.find("select * from w_db_model_item where w_model_id = ? order by serial", id);
  Generate generate = Generate.dao.findFirst("select * from w_generate where w_model_id = ?", id);

  // 查找出跟model有关的list
  List<Record> master = Db.find("select b.class_name, a.*, c.package, c.module_name from w_db_model_mapping a, w_db_model b, w_generate c where a.master_id = b.id and a.slaves_id = ? and a.master_id = c.w_model_id", id);
  // 查找出跟model相关的从表
  List<Record> slaves = Db.find("SELECT a.class_name, b.*, c.package, c.module_name FROM w_db_model a, w_db_model_mapping b, w_generate c WHERE a.id = b.slaves_id AND b.master_id = ? and c.w_model_id = b.slaves_id", id);

  Template t = gt.getTemplate("gen/web/4mysqlmd.btl");
  t.binding("model", model);
  t.binding("columns", columns);

  t.binding("generate", generate);
  t.binding("master", master);
  t.binding("slaves", slaves);
  // 是否使用驼峰命名
  t.binding("camelName", true);
  System.out.println(t.render());
}
 
开发者ID:slashchenxiaojun,项目名称:wall.e,代码行数:24,代码来源:TempletGenerateTest.java

示例7: 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

示例8: main

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

示例9: 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

示例10: testCore

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

	Map map = new HashMap();
	map.put("a", "hi");
	map.put("b", 1);

	Template t = gt.getTemplate("/function/function_template.html");
	t.binding(map);
	String str = t.render();
	AssertJUnit.assertEquals(this.getFileContent("/function/function_expected.html"), str);

	t = gt.getTemplate("/function/function_template.html");
	t.binding(map);
	str = t.render();
	AssertJUnit.assertEquals(this.getFileContent("/function/function_expected.html"), str);
}
 
开发者ID:javamonkey,项目名称:beetl2.0,代码行数:19,代码来源:FunctionTest.java

示例11: testArrayMap

import org.beetl.core.Template; //导入方法依赖的package包/类
@Test
public void testArrayMap() throws Exception
{
	Template t = gt.getTemplate("/exp/set_template.html");
	int[] c = new int[]{1,2};
	int[][] d = new int[][]{{1,2},{3,4}};
	t.binding("c", c);
	t.binding("d", d);
	String str = t.render();
	AssertJUnit.assertEquals(this.getFileContent("/exp/set_expected.html"), str);

	t = gt.getTemplate("/exp/set_template.html");
	t.binding("c", c);
	t.binding("d", d);
	str = t.render();
	AssertJUnit.assertEquals(this.getFileContent("/exp/set_expected.html"), str);
}
 
开发者ID:javamonkey,项目名称:beetl2.0,代码行数:18,代码来源:SetTest.java

示例12: testPojo

import org.beetl.core.Template; //导入方法依赖的package包/类
@Test
public void testPojo() throws Exception
{
	Template t = gt.getTemplate("/exp/set_pojo_template.html");
	User user = new User("joelli");
	User lover = new User("lucymiao");
	t.binding("user", user);
	t.binding("lover", lover);
	String str = t.render();
	AssertJUnit.assertEquals(this.getFileContent("/exp/set_pojo_expected.html"), str);

	t = gt.getTemplate("/exp/set_pojo_template.html");
	t.binding("user", user);
	t.binding("lover", lover);
	str = t.render();
	AssertJUnit.assertEquals(this.getFileContent("/exp/set_pojo_expected.html"), str);
}
 
开发者ID:javamonkey,项目名称:beetl2.0,代码行数:18,代码来源:SetTest.java

示例13: generateModel

import org.beetl.core.Template; //导入方法依赖的package包/类
public void generateModel(DbModel model, String templatePath, Map<String, Object> paras) {
  if ( StrKit.isBlank(templatePath) ) templatePath = MAVEN_BASE + "gen/pojo/4ActiveRecordEnhance.btl";
  Template t_pojo = gt.getTemplate(templatePath);
  t_pojo.binding(paras);
  Generate generate = (Generate) paras.get("generate");

  File file = getCodeGenerateFile(generate, "model", model.getClassName() + ".java");
  System.out.println(file.getAbsolutePath());
  try {
    FileKit.write(t_pojo.render(), file);
  } catch ( FileNotFoundException | BeetlException e ) {
    e.printStackTrace();
  }
  System.out.println("############generateModel success############");
}
 
开发者ID:slashchenxiaojun,项目名称:wall.e,代码行数:16,代码来源:TempletGenerate.java

示例14: generateController

import org.beetl.core.Template; //导入方法依赖的package包/类
public void generateController(DbModel model, String templatePath, Map<String, Object> paras) {
  if ( StrKit.isBlank(templatePath) ) templatePath = MAVEN_BASE + "gen/web/4Jfinalcontroller.btl";
  Template t_pojo = gt.getTemplate(templatePath);
  t_pojo.binding(paras);
  Generate generate = (Generate) paras.get("generate");

  File file = getCodeGenerateFile(generate, "controller", model.getClassName() + "Controller.java");
  System.out.println(file.getAbsolutePath());
  try {
    FileKit.write(t_pojo.render(), file);
  } catch ( FileNotFoundException | BeetlException e ) {
    e.printStackTrace();
  }
  System.out.println("############generateController success############");
}
 
开发者ID:slashchenxiaojun,项目名称:wall.e,代码行数:16,代码来源:TempletGenerate.java

示例15: generateService

import org.beetl.core.Template; //导入方法依赖的package包/类
public void generateService(DbModel model, String templatePath, Map<String, Object> paras) {
  if ( StrKit.isBlank(templatePath) ) templatePath = MAVEN_BASE + "gen/web/4webservice.btl";
  Template t_pojo = gt.getTemplate(templatePath);
  t_pojo.binding(paras);
  Generate generate = (Generate) paras.get("generate");

  File file = getCodeGenerateFile(generate, "service", model.getClassName() + "Service.java");
  System.out.println(file.getAbsolutePath());
  try {
    FileKit.write(t_pojo.render(), file);
  } catch ( FileNotFoundException | BeetlException e ) {
    e.printStackTrace();
  }
  System.out.println("############generateService success############");
}
 
开发者ID:slashchenxiaojun,项目名称:wall.e,代码行数:16,代码来源:TempletGenerate.java


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