title: Passing a function into a Handlebars template
body: <p>I'm using (or at least starting with) <a href="http://handlebarsjs.com" rel="noreferrer">HandlebarsJS</a> for the html templates but I might have hit a dead end. What I want is to pass a function to the template, e.g.</p>
  
  <pre><code>&lt;div id="divTemplate"&gt;
    &lt;span onclick="{{func}}"&gt;{{text}}&lt;/span&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>and then I would expect to have something like </p>
  
  <pre><code>var source = $('#divTemplate').html();
  var template = Handlebars.compile(source);
  
  var data = {
    "text": "Click here",
    "func": function(){
      alert("Clicked");
    }
  };
  
  $('body').append(template(data));
  </code></pre>
  
  <p>But the function is executed on init, it is not passed into the template and the result is: </p>
  
  <pre><code>&lt;span onclick=""&gt;Click here&lt;/span&gt;.
  </code></pre>
  
  <p>I was trying some stuff with the helper functions as well but I couldn't make it work too. Any ideas would be appreciated. :) </p>