|
2 | 2 |
|
3 | 3 | import java.io.IOException; |
4 | 4 | import java.util.List; |
| 5 | +import java.util.Map; |
5 | 6 |
|
6 | 7 | import org.slf4j.Logger; |
7 | 8 | import org.slf4j.LoggerFactory; |
8 | 9 |
|
9 | | -import com.fasterxml.jackson.databind.JsonNode; |
10 | | -import com.github.jknack.handlebars.Context; |
11 | 10 | import com.github.jknack.handlebars.Handlebars; |
12 | 11 | import com.github.jknack.handlebars.Helper; |
13 | | -import com.github.jknack.handlebars.JsonNodeValueResolver; |
14 | 12 | import com.github.jknack.handlebars.Template; |
15 | 13 | import com.github.jknack.handlebars.cache.ConcurrentMapTemplateCache; |
16 | 14 | import com.github.jknack.handlebars.io.ClassPathTemplateLoader; |
@@ -87,23 +85,15 @@ public String rednerRawTemplate(String rawTemplate, Object data) { |
87 | 85 | } |
88 | 86 |
|
89 | 87 | private String render(Template template, Object data) { |
90 | | - Context context = null; |
91 | 88 | try { |
92 | | - JsonNode node = Json.serializer().nodeFromObject(data); |
93 | | - // Very useful for debugging templates |
| 89 | + // Can't currently get the jackson module working not sure why. |
| 90 | + Map<String, Object> jsonMap = Json.serializer().mapFromJson(Json.serializer().toString(data)); |
94 | 91 | if (log.isDebugEnabled()) { |
95 | | - log.debug("rendering template " + template.filename() + "\n" + Json.serializer().toPrettyString(node)); |
| 92 | + log.debug("rendering template " + template.filename() + "\n" + Json.serializer().toPrettyString(jsonMap)); |
96 | 93 | } |
97 | | - context = Context.newBuilder(node) |
98 | | - .resolver(JsonNodeValueResolver.INSTANCE) |
99 | | - .build(); |
100 | | - return template.apply(context); |
| 94 | + return template.apply(jsonMap); |
101 | 95 | } catch (IOException e) { |
102 | 96 | throw new RuntimeException(e); |
103 | | - } finally { |
104 | | - if (null != context) { |
105 | | - context.destroy(); |
106 | | - } |
107 | 97 | } |
108 | 98 | } |
109 | 99 |
|
|
0 commit comments