Research: templating engine - imkarin/bloktech GitHub Wiki

Some of the most popular and recommended templating engines are EJS, Pug and Handlebars. I'll look into the details of these engines and compare them side by side.

EJS

EJS syntax

Pros

  • Uses complete JavaScript logic.
  • HTML remains the same before and after rendering, because EJS only runs within the <% %> tags.
  • Superfast to learn, almost no new syntax.
  • Powerful built-in error handling that shows you line numbers on which errors occur.

Cons

  • Cryptic syntax, kind of difficult to read.
  • No support for block by default, to reuse pieces of templates.

Pug

Pug syntax

Pros

  • Clear syntax, easy to read.
  • Sublayouts are easy to make using block and extends.
  • Identation reflects nesting.
  • Allows writing inline JavaScript, directly into the template.
  • High performance on server and client side.

Cons

  • You can't copy HTML examples from the internet, without having to convert them to pug first.
  • Unforgiving in case of indentation errors.
  • Doesn't always work well with native HTML.
  • No streaming or asynchronous calls.

Handlebars

Handlebars syntax

Pros

  • Multiple implementations: JavaScript, Java, Ruby, Scala, .Net & PHP, making it useful for front and back end.
  • Clear syntax, easy to read using the {{ and }} tags.
  • Easy to copy examples from the internet and change them to your project's needs.

Cons

  • Documentation is not clear, hard to use.
  • Still an HTML code, which means no added design speed or better readability.
  • Not very well supported by editors (autocomplete etc.)
  • Doesn't work well with frameworks like Angular.js.

Source: slant.co

⚠️ **GitHub.com Fallback** ⚠️