title: Pass in array to JavaScript function using Mustache variable tag
body: <p>I'm using <strong>Node.js Express</strong> with <strong>Hogan</strong> templates, which I believe uses <strong>Mustache</strong> variable tags. I have a JavaScript array that I'm trying to pass into a JavaScript function that is part of my hogan template. Here is an example of what I am trying to do:</p>
  
  <p><a href="https://jsfiddle.net/z1ga8wgw/" rel="nofollow noreferrer">https://jsfiddle.net/z1ga8wgw/</a></p>
  
  <p>If you check the JavaScript console and click on the error in there, you will notice that the template expanded into this, which gives an error:</p>
  
  <pre><code>function test([object Object],[object Object],[object Object]) {
      console.log('test');
  }
  </code></pre>
  
  <p>The error I get in my actual application is:</p>
  
  <pre><code>Uncaught SyntaxError: Unexpected identifier
  </code></pre>
  
  <p>The error from JSFiddle gives is this:</p>
  
  <pre><code>Uncaught SyntaxError: Unexpected identifier
      at DOMEval (jquery-git.js:82)
      at domManip (jquery-git.js:5782)
      at jQuery.fn.init.append (jquery-git.js:5918)
      at HTMLDocument.&lt;anonymous&gt; ((index):61)
      at mightThrow (jquery-git.js:3569)
      at process (jquery-git.js:3637)
  </code></pre>
  
  <p>I would like to be able to have one array as the argument, but as you can see, the amount of arguments can vary. I would settle for this type of behavior as well if there isn't an error because I believe you can use the <strong>arguments</strong> variable, but just one parameter would be best, if that's possible.</p>
  
  <hr>
  
  <p><strong>Edit</strong></p>
  
  <p>Here is the test code from the JSFiddle (which also has Mustache and JQuery as resources that I'm not listing here):</p>
  
  <p><strong>HTML</strong></p>
  
  <pre><code>&lt;div id="output"&gt;&lt;/div&gt;
  
  &lt;script type="text/html" id="test"&gt;
      &lt;script&gt;
      function test({{data}}) {
          console.log('test');
      }
      &lt;/script&gt;
  &lt;/script&gt;
  </code></pre>
  
  <p><strong>JavaScript:</strong></p>
  
  <pre><code>// Got help with this template from: http://jsfiddle.net/evildonald/hqAnK/
  $(document).ready(function () {
      var output = $("#output");    
      var template = $("#test").html();
  
      var data = { data : [
          {value : "1", text : "text 1"},
          {value : "2", text : "text 2"},
          {value : "3", text : "text 3"}
      ]};
  
      html = Mustache.render(template, data);
      output.append(html);
  });
  </code></pre>