Template Engines - Falicer/Project_Tech_2021 GitHub Wiki

Node JS logo There are a few template engines you can use with Express and Node JS, here's a few.
The images will link towards the site

Mustache

Mustache
mustache.js is a zero-dependency implementation of the mustache template system in JavaScript.

Mustache is a logic-less template syntax. It can be used for HTML, config files, source code - anything. It works by expanding tags in a template using values provided in a hash or object.

We call it "logic-less" because there are no if statements, else clauses, or for loops. Instead there are only tags. Some tags are replaced with a value, some nothing, and others a series of values.

Works great in these text editors

  • TextMate
  • Vim
  • Emacs
  • Coda
  • Atom

Handlebars

Handlebars
Handlebars helps you build semantic templates with no frustration, it's largely compatible with mustache templates and it's even interchangeable. The templates are compiled in JavaScript functions which makes the execution faster than most template engines.

Works great in these editors

  • Atom
  • VSCode
  • Any editor with a terminal for fast use!

Can be used in editors without a terminal but you would need a terminal program for optimal useage.

EJS

EJS

EJS is an Effective templating language that lets you generate HTML markups with plan JavaScript.
With it's simple syntaxing, fast development time and speedy execution it.
EJS also makes it easy to debug your errors with line numbers included.
It's great community of active users makes sure that it's always under development to become better and better.

Works great in these editors

  • Atom
  • Brackets
  • VSCode
  • Sublime Text

Nunjucks

Nunjucks
Nunjucks is a powerful template engine with block inheritance, autoescaping, macros, asynchronous control and more. It's high performance is due to it's small file size and it has a wide variety of custom filters and extensions. It's available in node and all modern web browsers.

Works great in these editors

  • Atom
  • VSCode
  • Any editor with a terminal for fast use!

So which one will I use?

At this point I'm using handlebars, mostly because there's more available help with this engine if I get stuck, which is bound to happen.

Sources

ExpressJS. (2020). Template Engines. Retrieved May 22, 2021, from https://expressjs.com/en/resources/template-engines.html

Ivanovs, A. (2019, June 13). Alex Ivanovs. Retrieved May 22, 2021, from https://colorlib.com/wp/top-templating-engines-for-javascript/

node.js authors. (2016, August 2). Node JS [Logo]. Retrieved from https://commons.wikimedia.org/wiki/File:Node.js_logo.svg

{{ mustache }}. (2020). Retrieved May 22, 2021, from https://mustache.github.io/

Nunjucks. (2020). Nunjucks. Retrieved May 22, 2021, from https://mozilla.github.io/nunjucks/