title: mustache.js - can't get external template with jQuery get() method
body: <p>I would like to include an external template in my main page with jQuery's get() method but I have an issue.  </p>
  
  <p>The following message is displayed in the Web browser's console :</p>
  
  <blockquote>
    <p>TypeError: Invalid template! Template should be a "string" but "undefined" was given as the first argument for mustache#render(template, view, partials) - (mustache.min.js:1:9011)</p>
  </blockquote>
  
  <p><strong>index.html</strong>  </p>
  
  <pre><code>&lt;!doctype html&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;meta charset="utf-8"&gt;
      &lt;title&gt;&lt;/title&gt;
  &lt;/head&gt;
  &lt;body onload="myTemplate()"&gt;
      &lt;div id="target"&gt;Loading ... &lt;/div&gt;
  
      &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js"&gt;&lt;/script&gt;
      &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/mustache.js/2.2.1/mustache.min.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript" src="my-script.js"&gt;&lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>templates.html</strong></p>
  
  <pre><code>&lt;script id="tpl-1" type="text/html"&gt;
      &lt;p&gt;{{ name }} wins {{ calc }} points&lt;/p&gt;
  &lt;/script&gt;
  </code></pre>
  
  <p><strong>my-script.js</strong></p>
  
  <pre><code>// my-script.js
  
  function myTemplate() {
  
      $.get("tpl/templates.html", function(templates) {
          var template = $(templates).filter("#tpl-1").html();
  
          var data = {
              name: "Guy",
              calc: function () {
              return 8 + 2;
              }
          };
  
          var rendered = Mustache.render(template, data);
          $('#target').html(rendered);
      });
  }
  </code></pre>
  
  <p>Nevertheless it works well with load() method :</p>
  
  <pre><code>// my-script.js
  
  function myTemplate() {
  
      $("#target").load("tpl/templates.html #tpl-1", function() {
          var template = $("#tpl-1").html();
  
          var data = {
              name: "Guy",
              calc: function() {
                  return 8 + 2;
              }
          };
  
          var rendered = Mustache.render(template, data);
          $('#target').html(rendered);
      });
  }
  </code></pre>
  
  <p>Have you got an idea to run the get() method ?</p>