Skip to content

Commit fb828df

Browse files
committed
Add unit test for the template with ${} variable wrapper, for issue #45.
1 parent bf25ff1 commit fb828df

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/test/java/com/github/underscore/UtilityTest.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,19 @@ public void templateEach() {
257257
put("evaluate", "<%([\\s\\S]+?)%>"); } });
258258
}
259259

260+
@Test
261+
public void templateEach2() {
262+
$.templateSettings(new HashMap<String, String>() { { put("interpolate", "\\$\\{([\\s\\S]+?)\\}");
263+
put("evaluate", "\\{\\{([\\s\\S]+?)\\}\\}"); } });
264+
String list = "{{ _.each(items, function(item) { }} <li>${ item }</li> {{ }); }}";
265+
Template<Set<Map.Entry<String, Object>>> compiled3 = $.template(list);
266+
assertEquals(" <li>moe</li> <li>curly</li> <li>larry</li> ",
267+
compiled3.apply((new LinkedHashMap<String, Object>() { {
268+
put("items", asList("moe", "curly", "larry")); } }).entrySet()));
269+
$.templateSettings(new HashMap<String, String>() { { put("interpolate", "<%=([\\s\\S]+?)%>");
270+
put("evaluate", "<%([\\s\\S]+?)%>"); } });
271+
}
272+
260273
/*
261274
var template = _.template("<b><%- value %></b>");
262275
template({value: '<script>'});

0 commit comments

Comments
 (0)