title: Does Handlebars.js allow for dynamic templates?
body: <p>I have started to play around with the Spotify API as a personal learning exercise and started with the beginners tutorial.</p>
  
  <p>The example code given uses handlebars.js for templates and I actually think its pretty cool.  how ever I can't figure out a way to do what I want to accomplish.</p>
  
  <p>This is my template </p>
  
  <pre><code>&lt;script id="recently-played-template" type="text/x-handlebars-template"&gt;
  
      &lt;div class=""&gt;
        &lt;dl class="dl-horizontal"&gt;
          &lt;h3&gt; Recently Played &lt;/h3&gt;
  
      &lt;p&gt;{{items.0.track.artists.0.name}} - {{items.0.track.name}}&lt;/p&gt; 
  
        &lt;/dl&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/script&gt; 
  </code></pre>
  
  <p>I am doing the following call to the spotify API. Upon success it will fill the template with that JSON response data which then gets put in a placeholder div to display the data to the user</p>
  
  <pre><code>        $.ajax({
              url: 'https://api.spotify.com/v1/me/player/recently-played',
              headers: {
                'Authorization': 'Bearer ' + access_token
              },
              success: function(response) {
                recentlyPlayedPlaceholder.innerHTML = recentlyPlayedTemplate(response);
  
  
                $('#login').hide();
                $('#loggedin').show();
              }
          });
  </code></pre>
  
  <p>SO what I am trying to figure out how to do is to build my template in a way that based on how many tracks are returned.</p>
  
  <p>Lets say a user hasn't used spotify in a week and then listens to 3 songs. then I want 3 songs displayed.</p>
  
  <p>if they listened to 10 I want 10 displayed.</p>
  
  <p>I just am not sure how to make the template dynamic.</p>
  
  <p>I don't need the straight answer just a push in the right direction.any help is apprecaited.</p>