本文整理汇总了Java中org.beetl.core.Template类的典型用法代码示例。如果您正苦于以下问题:Java Template类的具体用法?Java Template怎么用?Java Template使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Template类属于org.beetl.core包,在下文中一共展示了Template类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: 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
示例3: 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
示例4: 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
示例5: 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
示例6: 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
示例7: 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
示例8: 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
示例9: testUserAttribute
import org.beetl.core.Template; //导入依赖的package包/类
@Test
public void testUserAttribute() throws Exception
{
User user = User.getTestUser();
Template t = gt.getTemplate("/va/va_simple_template.html");
this.bind(t, "user", user);
String str = t.render();
AssertJUnit.assertEquals(this.getFileContent("/va/va_simple_expected.html"), str);
t = gt.getTemplate("/va/va_simple_template.html");
this.bind(t, "user", user);
str = t.render();
AssertJUnit.assertEquals(this.getFileContent("/va/va_simple_expected.html"), str);
}
开发者ID:javamonkey,项目名称:beetl2.0,代码行数:18,代码来源:SimpleVATest.java
示例10: testMapAttribute
import org.beetl.core.Template; //导入依赖的package包/类
@Test
public void testMapAttribute() throws Exception
{
User user = User.getTestUser();
Map map = new HashMap();
map.put("name", "joelli");
map.put("salary", 10000.01);
Template t = gt.getTemplate("/va/va_map_template.html");
this.bind(t, "user", user, "map", map);
String str = t.render();
AssertJUnit.assertEquals(this.getFileContent("/va/va_map_expected.html"), str);
t = gt.getTemplate("/va/va_map_template.html");
this.bind(t, "user", user, "map", map);
str = t.render();
AssertJUnit.assertEquals(this.getFileContent("/va/va_map_expected.html"), str);
}
开发者ID:javamonkey,项目名称:beetl2.0,代码行数:21,代码来源:SimpleVATest.java
示例11: testFunctionAttribute
import org.beetl.core.Template; //导入依赖的package包/类
@Test
public void testFunctionAttribute() throws Exception
{
gt.registerFunction("userArray", new Function() {
@Override
public Object call(Object[] paras, Context ctx)
{
// TODO Auto-generated method stub
return new Object[]
{ User.getTestUser(), "a" };
}
});
Template t = gt.getTemplate("/va/va_fun_template.html");
String str = t.render();
AssertJUnit.assertEquals(this.getFileContent("/va/va_fun_expected.html"), str);
t = gt.getTemplate("/va/va_fun_template.html");
str = t.render();
AssertJUnit.assertEquals(this.getFileContent("/va/va_fun_expected.html"), str);
}
开发者ID:javamonkey,项目名称:beetl2.0,代码行数:25,代码来源:SimpleVATest.java
示例12: testDynamicAll
import org.beetl.core.Template; //导入依赖的package包/类
@Test
public void testDynamicAll() throws Exception
{
Map map = new HashMap();
map.put("name", "joelli");
map.put("age", 36);
Template t = gt.getTemplate("/type/dynamic_all_template.html");
this.bind(t, "user", map);
String str = t.render();
AssertJUnit.assertEquals(this.getFileContent("/type/dynamic_all_expected.html"), str);
User user = User.getTestUser();
t = gt.getTemplate("/type/dynamic_all_template.html");
this.bind(t, "user", user);
str = t.render();
AssertJUnit.assertEquals(this.getFileContent("/type/dynamic_all_expected.html"), str);
}
开发者ID:javamonkey,项目名称:beetl2.0,代码行数:19,代码来源:DynamicTest.java
示例13: testDynamicUser
import org.beetl.core.Template; //导入依赖的package包/类
@Test
public void testDynamicUser() throws Exception
{
Map map = new HashMap();
map.put("name", "joelli");
map.put("age", 36);
Template t = gt.getTemplate("/type/dynamic_user_template.html");
this.bind(t, "user", map);
String str = t.render();
AssertJUnit.assertEquals(this.getFileContent("/type/dynamic_user_expected.html"), str);
User user = User.getTestUser();
t = gt.getTemplate("/type/dynamic_user_template.html");
this.bind(t, "user", user);
str = t.render();
AssertJUnit.assertEquals(this.getFileContent("/type/dynamic_user_expected.html"), str);
}
开发者ID:javamonkey,项目名称:beetl2.0,代码行数:19,代码来源:DynamicTest.java
示例14: 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
示例15: 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
示例16: testInclude
import org.beetl.core.Template; //导入依赖的package包/类
@Test
public void testInclude() throws Exception
{
User user = User.getTestUser();
Template t = gt.getTemplate("/tag/include_template.html");
this.bind(t, "user", user);
String str = t.render();
AssertJUnit.assertEquals(this.getFileContent("/tag/include_expected.html"), str);
t = gt.getTemplate("/tag/include_template.html");
this.bind(t, "user", user);
str = t.render();
AssertJUnit.assertEquals(this.getFileContent("/tag/include_expected.html"), str);
}
开发者ID:javamonkey,项目名称:beetl2.0,代码行数:18,代码来源:IncludeTest.java
示例17: 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
示例18: testLayout
import org.beetl.core.Template; //导入依赖的package包/类
@Test
public void testLayout() throws Exception
{
User user = User.getTestUser();
Template t = gt.getTemplate("/tag/layout_template.html");
this.bind(t, "user", user);
String str = t.render();
AssertJUnit.assertEquals(this.getFileContent("/tag/layout_expected.html"), str);
t = gt.getTemplate("/tag/layout_template.html");
this.bind(t, "user", user);
str = t.render();
AssertJUnit.assertEquals(this.getFileContent("/tag/layout_expected.html"), str);
}
开发者ID:javamonkey,项目名称:beetl2.0,代码行数:18,代码来源:LayoutTagTest.java
示例19: 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);
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
示例20: testEmptyTag
import org.beetl.core.Template; //导入依赖的package包/类
@Test
public void testEmptyTag() throws Exception
{
//将默认搜索路径更改到tag目录下
gt.registerTag("tagbinding", VarBindingSampleTag.class);
Template t = gt.getTemplate("/tag/binding/tagbinding_template.html");
String str = t.render();
AssertJUnit.assertEquals(this.getFileContent("/tag/binding/tagbinding_expected.html"), str);
t = gt.getTemplate("/tag/binding/tagbinding_template.html");
str = t.render();
AssertJUnit.assertEquals(this.getFileContent("/tag/binding/tagbinding_expected.html"), str);
}
开发者ID:javamonkey,项目名称:beetl2.0,代码行数:17,代码来源:HtmlVarBinddingTagTest.java
注:本文中的org.beetl.core.Template类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论