title: Getting template using ajax in Mustache Js
body: <p>For concatenating HTML tags and dynamic data, and insert the resulting UI markup into the DOM, I am using Mustache Js.</p>
  
  <p>Below is the example code.</p>
  
  <p>main.blade.php:</p>
  
  <pre><code>$.getJSON('json/data2.json', function(data) {
  var template = $('#personTpl').html();
  var html = Mustache.to_html(template, data);
  $('#sampleArea').html(html);
  });
  </code></pre>
  
  <p>The template is defined as follows in index.html:</p>
  
  <pre><code>&lt;script id="personTpl" type="text/template"&gt;
  &lt;h1&gt;{{firstName}} {{lastName}}&lt;/h1&gt;
  &lt;p&gt;Blog URL: &lt;a href="{{blogURL}}"&gt;{{blogURL}}&lt;/a&gt;&lt;/p&gt;
  &lt;/script&gt;
  </code></pre>
  
  <p>According to above code we are including the index.html(template) page in main.blade.php page. It is possible to access the index.html(template) page using ajax and append data from the current page. </p>
  
  <p>And by this I can maintain the code easily and include the index.html(template) if i needed.</p>