Skip to content

Instantly share code, notes, and snippets.

@jeff-hager-dev
Created December 11, 2014 18:17
Show Gist options
  • Save jeff-hager-dev/4092236d8fbf29fbc3ce to your computer and use it in GitHub Desktop.
Save jeff-hager-dev/4092236d8fbf29fbc3ce to your computer and use it in GitHub Desktop.
Playing around with a way to dynamically load handlebar templates. I know there are other ways to do it but I wanted to try myself.
(function(exports){
layouts = {
'layoutName':'url-for-layout'
}
exports.layoutHelper = {
getLayout: function(layoutName){
var layoutObj = '';
$.ajax({
url: layouts[layoutName],
type: 'GET',
async: false,
cache: false,
timeout: 30000,
error: function(){ layoutObj = ""; },
success: function(data){ layoutObj = data; },
});
return layoutObj;
},
}
})(window);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment