jeff-hager-dev
12/11/2014 - 6:17 PM

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.

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);