Here is the method I found:
private String renderMustacheContent() throws IOException { MustacheFactory mf = new DefaultMustacheFactory(); Mustache mustache; if (type.getTemplate().trim().isEmpty()) { String emailContent = genCpuEmailContent(cmsKey); mustache = mf.compile(new StringReader(emailContent), "cpu.template.email"); } else { mustache = mf.compile(type.getTemplate()); } StringWriter writer = new StringWriter(); mustache.execute(writer, values).flush(); return writer.toString(); }
So basically, when you just want to display email from a String template and not from a file, just create a new StringReader using the template.
source share