File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed
main/java/com/github/underscore
test/java/com/github/underscore Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -39,8 +39,6 @@ public class $<T> {
3939 put ("interpolate" , "<%=([\\ s\\ S]+?)%>" );
4040 put ("escape" , "<%-([\\ s\\ S]+?)%>" );
4141 } };
42- private static final int GROUP_INDEX_2 = 2 ;
43- private static final int GROUP_INDEX_3 = 3 ;
4442 private static final int ARRAY_SIZE_2 = 2 ;
4543 private static final int MIN_PASSWORD_LENGTH_8 = 8 ;
4644 private static final long CAPACITY_SIZE_5 = 5L ;
@@ -123,6 +121,10 @@ public String apply(Map<K, V> value) {
123121 "\\ s*\\ Q" + ((Map .Entry ) element ).getKey ()
124122 + "\\ E\\ s*" )).matcher (result ).replaceAll (escape (String .valueOf (((Map .Entry ) element )
125123 .getValue ())));
124+ result = java .util .regex .Pattern .compile (evaluate .replace (ALL_SYMBOLS ,
125+ "\\ s*\\ Q" + ((Map .Entry ) element ).getKey ()
126+ + "\\ E\\ s*" )).matcher (result ).replaceAll (String .valueOf (((Map .Entry ) element )
127+ .getValue ()));
126128 }
127129 return result ;
128130 }
Original file line number Diff line number Diff line change @@ -250,6 +250,14 @@ public void templateValue2() {
250250 put ("name" , "moe" ); put ("value" , "<script>" ); } }));
251251 }
252252
253+ @ Test
254+ public void templateValue3 () {
255+ Template <Map <String , Object >> template = $ .template ("hello: <% name %>, <b><%- value %></b>" );
256+ assertEquals ("hello: moe, <b><script></b>" ,
257+ template .apply (new LinkedHashMap <String , Object >() { {
258+ put ("name" , "moe" ); put ("value" , "<script>" ); } }));
259+ }
260+
253261/*
254262var object = {cheese: 'crumpets', stuff: function(){ return 'nonsense'; }};
255263_.result(object, 'cheese');
You can’t perform that action at this time.
0 commit comments