예제 #1
0
 /** 渲染Template文件. */
 public static String renderTemplate(Template template, Object model) {
   try {
     StringWriter result = new StringWriter();
     template.process(model, result);
     return result.toString();
   } catch (Exception e) {
     throw Exceptions.unchecked(e);
   }
 }
예제 #2
0
 /** 渲染模板字符串。 */
 public static String renderString(String templateString, Map<String, ?> model) {
   try {
     StringWriter result = new StringWriter();
     Template t = new Template("default", new StringReader(templateString), new Configuration());
     t.process(model, result);
     return result.toString();
   } catch (Exception e) {
     throw Exceptions.unchecked(e);
   }
 }