Monday, September 8, 2014

Comparing Java Template Engines

This is more for general purpose use-case other than just for building web-apps e.g. creating HTML for EDMs.

A great guide here: http://www.slideshare.net/jreijn/comparing-templateenginesjvm

In summary:

  • If you need a designer-friendly system:
    • Thymeleaf
    • Mustache
  • If you are a stickler for the DRY (Don't Repeat Yourself) principle:
    • Jade generates HTML from scripts
  • Or if you prefer something more developer-friendly:
    • Freemarker
    • JSP listed as an option by presenter also
In my view, having something designer-friendly is why you use a temple engine in the first place. So the shortlist came down to Thymeleaf and Mustache, and Mustache wins out for simplicity and performance. Note though that Mustache may be too simple for some of your needs.

Friday, September 5, 2014

HTML Email Best Practices

The Internet community hasn't been totally unanimous on this but this seems to be the general consensus:

  • The DocType declaration should be there and it is recommended to use the XHTML 1.0 Transitional
  • It is recommended to use a fully formed HTML document with <html> and <body> tags
References:

HTML vs Plain Text Emails

These days both HTML and Plain Text emails have similar levels of deliverability, but with HTML emails there are the following concerns:

  • If HTML has errors and results in formatting issues and user can't read email properly, user may mark it as spam
  • If HTML email contains too much pictures and too little text there is a higher chance of spam filter marking is as spam
References:

AWS SES Send HTML Email With Java API

It is not clear in the documentation whether it is possible to send a multi-part email with both Plain Text and HTML components via AWS SES.

I did a test and verified that it is supported in this way:
Body body = new Body();
Content textContent = new Content().withData("text content");
body.withText(textContent);
Content htmlContent = new Content().withData("html content");
body.withHtml(htmlContent);

The resulting email will be a multi-part email with both Plain Text and HTML components.