freemarkers小改

This commit is contained in:
Calvin
2012-12-05 00:38:56 +08:00
parent 4b03ce4437
commit 07f77d85f7
2 changed files with 5 additions and 5 deletions
@@ -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