use of org.beetl.core.resource.ClasspathResourceLoader in project swift by luastar.
the class BeetlUtils method init.
private void init() {
try {
ClasspathResourceLoader resourceLoader = new ClasspathResourceLoader();
Configuration cfg = Configuration.defaultConfiguration();
groupTemplate = new GroupTemplate(resourceLoader, cfg);
} catch (Exception e) {
logger.error("转换为文件时异常", e);
}
}
use of org.beetl.core.resource.ClasspathResourceLoader in project vip by guangdada.
the class BeetlConfig method beetlConfiguration.
/**
* beetl的配置
*/
@Bean(initMethod = "init")
public BeetlConfiguration beetlConfiguration() {
BeetlConfiguration beetlConfiguration = new BeetlConfiguration();
beetlConfiguration.setResourceLoader(new ClasspathResourceLoader(BeetlConfig.class.getClassLoader(), beetlProperties.getPrefix()));
beetlConfiguration.setConfigProperties(beetlProperties.getProperties());
return beetlConfiguration;
}
use of org.beetl.core.resource.ClasspathResourceLoader in project vip by guangdada.
the class GunsTemplateEngine method initBeetlEngine.
public void initBeetlEngine() {
Properties properties = new Properties();
properties.put("RESOURCE.root", "");
properties.put("DELIMITER_STATEMENT_START", "<%");
properties.put("DELIMITER_STATEMENT_END", "%>");
properties.put("HTML_TAG_FLAG", "##");
Configuration cfg = null;
try {
cfg = new Configuration(properties);
} catch (IOException e) {
e.printStackTrace();
}
ClasspathResourceLoader resourceLoader = new ClasspathResourceLoader();
groupTemplate = new GroupTemplate(resourceLoader, cfg);
groupTemplate.registerFunctionPackage("tool", new ToolUtil());
}
use of org.beetl.core.resource.ClasspathResourceLoader in project vip by guangdada.
the class BeetlConfig method beetlConfiguration.
/**
* beetl的配置
*/
@Bean(initMethod = "init")
public BeetlGroupUtilConfiguration beetlConfiguration() {
BeetlGroupUtilConfiguration beetlConfiguration = new BeetlGroupUtilConfiguration();
beetlConfiguration.setResourceLoader(new ClasspathResourceLoader(BeetlConfig.class.getClassLoader(), beetlProperties.getPrefix()));
beetlConfiguration.setConfigProperties(beetlProperties.getProperties());
return beetlConfiguration;
}
use of org.beetl.core.resource.ClasspathResourceLoader in project beetl2.0 by javamonkey.
the class Test method main.
public static void main(String[] args) throws Exception {
ClasspathResourceLoader resourceLoader = new ClasspathResourceLoader("org/beetl/core/lab/");
Configuration cfg = Configuration.defaultConfiguration();
cfg.setDirectByteOutput(true);
cfg.getResourceMap().put("tagRoot", "/");
cfg.getPkgList().add("org.beetl.core.lab.");
GroupTemplate gt = new GroupTemplate(resourceLoader, cfg);
// cfg.setStatementStart("@");
// cfg.setStatementEnd(null);
// cfg.setPlaceholderStart("{{");
// cfg.setPlaceholderEnd("}}");
//
gt.registerFunction("test", new TestFun());
gt.registerTag("test", TestTag.class);
List list = new ArrayList();
list.add(null);
list.add(new TestUser("abc"));
HashMap map = new HashMap();
map.put("key", 123);
gt.enableStrict();
for (int i = 0; i < 1; i++) {
Template t = gt.getTemplate("/hello.txt");
t.binding("user", new TestUser("jo"));
t.binding("id", 2);
t.binding("list", list);
ByteArrayOutputStream bs = new ByteArrayOutputStream();
try {
t.renderTo(bs);
} catch (Exception ex) {
ex.printStackTrace();
}
// TestUser test = new TestUser("a");
// test.setLover(new TestUser("b"));
// t.binding("user", test);
System.out.println(t.render());
}
}
Aggregations