Skip to content

Commit 0a73983

Browse files
committed
Switch back to non jackson module. Not working yet
1 parent 80f8206 commit 0a73983

2 files changed

Lines changed: 6 additions & 16 deletions

File tree

‎stubbornjava-common/src/main/java/com/stubbornjava/common/TemplateHelpers.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import com.github.jknack.handlebars.Options;
77

88
public class TemplateHelpers {
9-
private static final DateTimeFormatter MMMddyyyyFmt = DateTimeFormatter.ofPattern("MMM dd, yyyy");
9+
static final DateTimeFormatter MMMddyyyyFmt = DateTimeFormatter.ofPattern("MMM dd, yyyy");
1010

1111
public static CharSequence dateFormat(String dateString, Options options) {
1212
LocalDateTime date = LocalDateTime.parse(dateString);

‎stubbornjava-common/src/main/java/com/stubbornjava/common/Templating.java‎

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@
22

33
import java.io.IOException;
44
import java.util.List;
5+
import java.util.Map;
56

67
import org.slf4j.Logger;
78
import org.slf4j.LoggerFactory;
89

9-
import com.fasterxml.jackson.databind.JsonNode;
10-
import com.github.jknack.handlebars.Context;
1110
import com.github.jknack.handlebars.Handlebars;
1211
import com.github.jknack.handlebars.Helper;
13-
import com.github.jknack.handlebars.JsonNodeValueResolver;
1412
import com.github.jknack.handlebars.Template;
1513
import com.github.jknack.handlebars.cache.ConcurrentMapTemplateCache;
1614
import com.github.jknack.handlebars.io.ClassPathTemplateLoader;
@@ -87,23 +85,15 @@ public String rednerRawTemplate(String rawTemplate, Object data) {
8785
}
8886

8987
private String render(Template template, Object data) {
90-
Context context = null;
9188
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));
9491
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));
9693
}
97-
context = Context.newBuilder(node)
98-
.resolver(JsonNodeValueResolver.INSTANCE)
99-
.build();
100-
return template.apply(context);
94+
return template.apply(jsonMap);
10195
} catch (IOException e) {
10296
throw new RuntimeException(e);
103-
} finally {
104-
if (null != context) {
105-
context.destroy();
106-
}
10797
}
10898
}
10999

0 commit comments

Comments
 (0)