title: Creating multiple HTML files from a single Jade template with Grunt
body: <p>I'm looking to create multiple HTML files from a single Jade template using Grunt. </p>
  
  <p>Here's what I'm doing:</p>
  
  <ol>
  <li>Grabbing the JSON data from an external file</li>
  <li>Looping through that object</li>
  <li>Creating a grunt config task for each value in that JSON object</li>
  </ol>
  
  <p>Here's my code:</p>
  
  <pre><code>neighborhoods = grunt.file.readJSON('data/neighborhoods.json');
  
  for(var i = 0; i &lt; Object.keys(neighborhoods).length; i++) {
  
      var neighborhood = {
          "title" : Object.keys(neighborhoods)[i],
          "data"  : neighborhoods[Object.keys(neighborhoods)[i]]
      };
  
      grunt.config(['jade', neighborhood.title], {
          options: {
              data: function() {
                  return {
                      neighborhoods: neighborhood.data
                  }
              }
          },
          files: {
              "build/neighborhoods/&lt;%= neighborhood.title %&gt;.html": "layouts/neighborhood.jade"
          }
      });
  }
  </code></pre>
  
  <p>The problem that I'm running in to is this</p>
  
  <pre><code>Running "jade:Art Museum" (jade) task
  Warning: An error occurred while processing a template (Cannot read property 'title' of undefined). Use --force to continue.
  </code></pre>
  
  <p>If I make the filename a string, it runs fine but obviously creates all the files with the same filename, thus only creating one file. I need to make that filename dynamic.</p>