// js/modules/util.js // utility functions for template loading / .. (function (Util) { // cache Util.templates = {}; Util.preloadTemplates = function (names, callback) { var loadTemplate = function (index) { var name = names[index]; $.get('js/templates/' + name + '.handlebars', function (data) { Util.templates[name] = data; index++; if (index < names.length) { loadTemplate(index); } else { callback(); } }); } loadTemplate(0); } Util.getTemplate = function (name) { return Util.templates[name]; } })(app.module("util"));