title: Using dynamic variable names for arrays in dust js
body: <p>My model looks like: </p>
  
  <pre><code>var model = { 
      tagTypes : ["product", "location"],
      cards : [{
          title : "Card 1",
          product : ["prod1"],
          location : ["US", "UK"]
      },
      {
          title : "Card 2",
          product : ["prod2"],
          location : ["UK"]
      }]
  };
  </code></pre>
  
  <p>I am getting fields (this is a dynamic list &amp; it may change depending on response) for my "card" (i.e. product &amp; location in this case) as an array (tagTypes)</p>
  
  <p>I want to loop through elements of these fields one by one. I am able to get these lists in serialized form using my current dust template. But I want to actually loop through every individual element so that I may add some extra html in between.</p>
  
  <p>Current Dust template : </p>
  
  <pre><code> {#cards}
      {title} | 
      {#tagTypes card=.}
          {card[.]}
      {/tagTypes}
      &lt;br/&gt;
  {/cards}
  </code></pre>
  
  <p>Current Output : </p>
  
  <pre><code>Card 1 | product: [prod1] location: [US,UK] 
  Card 2 | product: [prod2] location: [UK] 
  </code></pre>
  
  <p>Required output (day) :</p>
  
  <pre><code>Card 1 | product: &lt;span class="tag"&gt;prod1&lt;/span&gt; location: &lt;span class="tag"&gt;US&lt;span&gt; &lt;span class="tag"&gt;UK&lt;/span&gt; 
  Card 2 | product: &lt;span class="tag"&gt;prod2&lt;/span&gt; location: &lt;span class="tag"&gt;UK&lt;/span&gt; 
  </code></pre>
  
  <p>See : <a href="http://jsfiddle.net/74nw7dm3/5/" rel="nofollow">http://jsfiddle.net/74nw7dm3/5/</a> for experimenting with above code. </p>