pug Iteration with Pug Each iteration


Build an app.js with a simple data store:

app.get("/bookstore", function (req, res, next) {
    // Your route data
   var bookStore = [
            title: "Templating with Pug",
            author: "Winston Smith",
            pages: 143,
            year: 2017        
            title: "Node.js will help",
            author: "Guy Fake",
            pages: 879,
            year: 2015        
    res.render("index", {
        bookStore: bookStore

Iterate over the data store using an index.pug file and an each loop:

each book in bookStore
    li= book.title
    li= book.author
    li= book.pages
    li= book.year

Result will be:

  <li>Templating with Pug</li>
  <li>Winston Smith</li>
  <li>Node.js will help</li>
  <li>Guy Fake</li>