Pug.js

An HTML templating code to speed up repetitive html pages. 1


[!Info] Guide Docs Github Demo

Getting Started


Package

To use Pug in your own JavaScript projects:

$ npm install pug

Command Line

After installing the latest version of Node.js, install with:

$ npm install pug-cli -g

and run with

$ pug --help

Demo


nav
  navbar-default  div
    h1 My Website!
  ul
    li
      a Home
    li
      a Page 1
    li
      a Page 2
  input

The code above compiles to this:

<nav>
  <div>
    <h1>My Website!</h1>
  </div>
  <ul>
    <li><a>Home</a></li>
    <li><a>Page 1</a></li>
    <li><a>Page 2</a></li>
  </ul>
  <input/>
</nav>

Further Info


Using template engines with Express

  1. This post was made using Obsidian - Ghost Publish. For instructions on how to use, follow the README or this Youtube video