amrumpler (1) [Avatar] Offline
#1
I've been able to output the html for my widget by appending the html to the DOM, however the html I'm displaying has to be defined in line. The book has an aside referencing Javascript Templating Libraries like Mustache, Handlebars and Hogan.js but I can't figure out how to use them in a third-party widget since I can't load the template files (html) via jquery.get() due to SOP and I can't load them using the loadScript function since they're really not JS.

Any tips for using any of these templating libraries would be greatly appreciated.
benvinegar (68) [Avatar] Offline
#2
Re: Templating Examples?
Hey there,

My advice is to have a build script that compiles your templates AND your JavaScript files into a single JavaScript bundle.

We use a plugin for Grunt called grunt-contrib-handlebars (https://github.com/gruntjs/grunt-contrib-handlebars) to compile our Handlebars templates this way.

- Ben