JS templating in Craft CP I'm writing a plugin where I need to render some semi-complex HTML clientside at runtime (all inside the CP).

Does Garnish (or any other library/framework/JS-thingamabob shipped with Craft) offer any built-in JS templating functionality a'la Handlebars or Underscore?
The only JS library that ships with Craft (besides the Craft-specific Garnish) is jQuery. Of course, jQuery is a helpful JS library, but by no means a full-fledged framework. Fortunately, adding a separate JS library is painfully easy!

How to CDN from a Twig template...

{% includeJsFile '//full/path/to/cdn.js' %}


How to CDN from PHP...

craft()-&gt;templates-&gt;includeJsFile('//full/path/to/cdn.js');


When you use includeJsFile, it wraps your path in a standard &lt;script&gt; tag... It doesn't matter where the file is, as long as the path is valid.

Keep in mind, a PHP call will take effect in both the back-end and front-end of your site. So to keep the file loaded only in your CP, make sure to wrap a conditional around it:

if (craft()-&gt;request-&gt;isCpRequest()) {
    craft()-&gt;templates-&gt;includeJsFile('//full/path/to/cdn.js');
}


Don't want to CDN? No problem! The best place to store local JS files would be in a resources folder:

/craft
  /plugins
    /myplugin
      /resources
        /js
          /handlebars.min.js


In that case, you can use includeJsResource instead of includeJsFile.