squido logosquido blog

Popular templating engines

Templating engines are essentially a way to generate HTML. Some of the benefits is the ability to insert variables/data, loop data to create HTML, conditional rendering and other clever rendering rules and formatting.

Some template engines look quite like HTML like Handlebars and EJS whereas others are vastly different and are indentation based like Pug.


Handlebars is based on the Mustache syntax using {{}} as the general variable delimiter. Some see the benefit of Handlebars is how closely it looks like HTML. This helps if you are familiar with HTML and simply want to extend by looping data, conditional rendering, formatting etc.

<ul class="people_list">
  {{#each people}}

Find out more


EJS is quite similar to Handlebars but has more of a Javascript feel with a <%%> variable delimiter. Similar to Handlebars, EJS is close to HTML which makes it easier to learn, read and debug if you are familiar with the HTML syntax.

  <% users.forEach(function(user){ %>
    <%- include('user/show', {user: user}) %>
  <% }); %>

Find out more


Pug (formally Jade) is quite a different syntax to the other template engines and allows for shorthand and indentation syntax quite like yaml.

Where something like this:

doctype html
   title Hello, World!
   h1 Hello, World!
     p Pug rocks!

Generates something like this:

<!DOCTYPE html>
<html lang="en">
    <title>Hello, World!</title>
    <h1>Hello, World!</h1>
    <div class="remark">
      <p>Pug rocks!!</p>

Find out more

Luckily, all of these are supported with squido and you can find our more here.

Related posts