How do I call this javascript function?
<p>As documented here: <a href="http://www.jblotus.com/2011/05/24/keeping-your-handlebars-js-templates-organized/" rel="nofollow">http://www.jblotus.com/2011/05/24/keeping-your-handlebars-js-templates-organized/</a></p>

<p>I am trying to use this function:</p>

<pre><code>(
    function getTemplateAjax(path, callback) {
        var source;
        var template;

        $.ajax({
            url: path,
                success: function(data) {
                    source    = data;
                    template  = Handlebars.compile(source);    

                    //execute the callback if passed
                    if (callback) callback(template);
            }
        });
    }

    //run our template loader with callback
    (getTemplateAjax('js/templates/handlebarsdemo.handlebars', function(source) {
        //do something with compiled template
        $('body').html(template);
    })()
)()
</code></pre>

<p>I am new to JS, so how can I use this?</p>

<p>I am trying to:</p>

<ol>
<li>pass the path of the handlebars file  </li>
<li>pass a json object which will be inserted in the template and an html should be returned back by the functions.</li>
</ol>

<p><strong>Update:</strong></p>

<p>Got the answer, there was a typo in the code: this works.</p>

<p>While calling the function, the argument was source but was being used as template.</p>

<pre><code>function getTemplateAjax(path, callback) {
    var source;
    var template;

    $.ajax({
        url: path,
            success: function(data) {
                source    = data;
                template  = Handlebars.compile(source);    
                if (callback) callback(template);
        }
    });
}

getTemplateAjax('js/templates/handlebarsdemo.handlebars', function(template) {
    data = {title: "hello!" , body: "world!"}
    $('body').html(template(data));
})
</code></pre>
