title: I am getting error while converting html to pug in express js
body: <p>I am new to node.js. I am getting this error </p>
  
  <blockquote>
    <p>TypeError: /home/agile/projects/nodekb/views/index.pug:6
        <br>4|   h1 #{title}
        <br>5|   ul
      <br>> 6|   each article, i in articles
        <br>7|     li= article.title</p>
    
    <p>Cannot read property 'length' of undefined
        at eval (eval at wrap (/home/agile/projects/nodekb/node_modules/pug-runtime/wrap.js:6:10),
    :28:32)
        at eval (eval at wrap (/home/agile/projects/nodekb/node_modules/pug-runtime/wrap.js:6:10),
    :47:4)
        at template (eval at wrap (/home/agile/projects/nodekb/node_modules/pug-runtime/wrap.js:6:10),
    :58:136)
        at Object.exports.renderFile (/home/agile/projects/nodekb/node_modules/pug/lib/index.js:427:38)
        at Object.exports.renderFile (/home/agile/projects/nodekb/node_modules/pug/lib/index.js:417:21)
        at View.exports.__express [as engine] (/home/agile/projects/nodekb/node_modules/pug/lib/index.js:464:11)
        at View.render (/home/agile/projects/nodekb/node_modules/express/lib/view.js:135:8)
        at tryRender (/home/agile/projects/nodekb/node_modules/express/lib/application.js:640:10)
        at Function.render (/home/agile/projects/nodekb/node_modules/express/lib/application.js:592:3)
        at ServerResponse.render (/home/agile/projects/nodekb/node_modules/express/lib/response.js:1008:7)</p>
  </blockquote>
  
  <p>here is my code,
  views/index.pug</p>
  
  <pre><code>extends layout
  
  block content
    h1 #{title}
    ul
      each article, i in articles
        li= article.title
  </code></pre>
  
  <p>app.js</p>
  
  <pre><code>const express = require('express');
  const path = require('path');
  
  //init app
  const app = express();
  
  //load  view engine
  app.set('views', path.join(__dirname, 'views'));
  app.set('view engine','pug');
  
  //home route
  app.get('/', function(req,res){
      let articles =[
          {
              id:1,
              title: 'Article 1',
              author: 'Bhakti Thakkar',
              body: 'This is article one'
          },
          {
              id:2,
              title: 'Article 2',
              author: 'Jeel Thakkar',
              body: 'This is article two'
          },
          {
              id:1,
              title: 'Article 3',
              author: 'Sonal Thakkar',
              body: 'This is article three'
          }
      ];
      res.render('index',{
          title:'Articles'
      });
  });
  
  
  //add route
  app.get("/articles/add",function(req,res){
      res.render('add_article',{
          title:'Add Articles'
      })
  });
  
  //start server
  app.listen(3000, function(){
      console.log('Server started on port 3000...');
  });
  </code></pre>
  
  <p>views/layout.pug</p>
  
  <pre><code>doctype html
  html
      head
          title Knowledgebase
      body   
          block content
          br
          hr
          footer
              p Copyright &amp;copy; 2018
  </code></pre>