The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

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