title: Iterating over an array of objects using Express and Jade
body: <p>I'm trying to render html using jade, and I want to iterate over an array of objects. For each object, I want to print all of the values on one line in an li. </p>
  
  <p>Here's my backend code using express: </p>
  
  <pre><code>router.get('/', function(req, res, next) {
    fs.readFile('./contacts.json', function(err, data){
      if (err) return res.status(400).send(err);
      var contactArr = JSON.parse(data);
      res.render('contacts', {contactArr : contactArr});
    });
  });
  </code></pre>
  
  <p>-- contactArr is an array of objects in JSON format like this:</p>
  
  <pre><code>[{"name":"Jennifer","email":"jennifer@yahoo.com"},{"name":"Mike","email":"miker@yahoo.com"}]
  </code></pre>
  
  <p>And here is the front end jade code that I'm trying to make work:</p>
  
  <pre><code>extends layout
  
  block content
    ul
      each contact in #{contactArr}
        li #{contact[0].name}
  </code></pre>
  
  <p>I've read all about iterating with jade here: <a href="http://jade-lang.com/reference/iteration/" rel="nofollow">http://jade-lang.com/reference/iteration/</a> , but I can't seem to get the syntax right for iterating over an array of objects to get out all the values. </p>
  
  <p>UPDATE:
  I realized that part of the problem was that I was attempt to reference the contactArr incorrectly. The #{ } syntax was unnecessary. Just "contactArr" in the jade code gives me access to the array. However, I am still struggling to figure out how to iterate over the keys in each object in the array.</p>