freemarkers小改
This commit is contained in:
@@ -17,10 +17,10 @@ public class FreeMarkers {
|
||||
/**
|
||||
* 渲染模板字符串。
|
||||
*/
|
||||
public static String rendereString(String templateString, Map<String, ?> model) {
|
||||
public static String renderString(String templateString, Map<String, ?> model) {
|
||||
try {
|
||||
StringWriter result = new StringWriter();
|
||||
Template t = new Template("name", new StringReader(templateString), new Configuration());
|
||||
Template t = new Template("default", new StringReader(templateString), new Configuration());
|
||||
t.process(model, result);
|
||||
return result.toString();
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -22,7 +22,7 @@ public class FreemarkersTest {
|
||||
public void renderString() {
|
||||
Map<String, String> model = Maps.newHashMap();
|
||||
model.put("userName", "calvin");
|
||||
String result = FreeMarkers.rendereString(TEMPLATE, model);
|
||||
String result = FreeMarkers.renderString(TEMPLATE, model);
|
||||
assertEquals("hello calvin", result);
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ public class FreemarkersTest {
|
||||
List<String> friends = Lists.newArrayList("a", "b", "c");
|
||||
|
||||
model.put("friends", friends);
|
||||
String result = FreeMarkers.rendereString("hello ${friends[0]}", model);
|
||||
String result = FreeMarkers.renderString("hello ${friends[0]}", model);
|
||||
assertEquals("hello a", result);
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public class FreemarkersTest {
|
||||
public void renderStringWithErrorTemplate() {
|
||||
Map<String, String> model = Maps.newHashMap();
|
||||
model.put("userName", "calvin");
|
||||
FreeMarkers.rendereString(ERROR_TEMPLATE, model);
|
||||
FreeMarkers.renderString(ERROR_TEMPLATE, model);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user