String subject = jsonTemplate.getString("subject");
String body = jsonTemplate.getString("body");
MustacheFactory mf = new DefaultMustacheFactory();
Mustache titleTemplate = mf.compile(new StringReader(subject), "subject");
Mustache bodyTemplate = mf.compile(new StringReader(body), "body");
// Subject
{
StringWriter sw = new StringWriter();
titleTemplate.execute(sw, parameters);
String formatted = sw.toString();
message.setSubject(formatted);
}
// Body
{
StringWriter sw = new StringWriter();
bodyTemplate.execute(sw, parameters);
String formatted = sw.toString();
message.setHtmlContent(formatted);
}
} catch(Exception e) {
logger.error("Unable load CouchDb e-mail template",e);