jade&pug

Using File in node

const pug = require('pug');

// Compile the source code
const compiledFunction = pug.compileFile('test.pug');

// Render a set of data in html
console.log(compiledFunction({"name": "Tim"}));

In 2015, jade was renamed to pug(by Timothy Gu)

<div>
  <h1>Ocean's Eleven</h1>
  <ul>
    <li>Comedy</li>
    <li>Thriller</li>
  </ul>
  <p>Danny Ocean and his eleven accomplices plan to rob
     three Las Vegas casinos simultaneously.</p>
</div>

Becomes

Fundamentals

  • handles <> and closing tag

  • spacing indicates nesting

  • . after tag lets you add many lines of text

  • Put | to just put more text

Attributes

  • ()

class shorthand

Inline Style

JS

Can directly use javascript with jade with - beginning line if no output and = if you want output

Can easily do loops and more with this

Jade also has loops

Interpolation

Mixins

Then call it with +

Last updated