Files
zulip/zephyr/static/js/templates.js
Tim Abbott bfd9287068 Append timestamp to URLs when getting templates on dev machines.
This prevents the templates from being cached by over-aggressive
chrome caching.

(imported from commit 1a1f7f697a823f6e806d3f2289c3bbda7e3f0d79)
2013-04-05 10:38:38 -04:00

29 lines
821 B
JavaScript

var templates = (function () {
var exports = {};
exports.render = function (name, arg) {
if (Handlebars.templates === undefined)
Handlebars.templates = {};
if (Handlebars.templates[name] === undefined) {
// Fetch the template using a synchronous AJAX request.
//
// This is only for local development. In prod we precompile
// templates and serve JavaScript which will have already
// populated Handlebars.templates.
$.ajax({
url: '/static/templates/'+name+'.handlebars?' + new Date().getTime(),
async: false,
success: function (data) {
Handlebars.templates[name] = Handlebars.compile(data);
}
});
}
return Handlebars.templates[name](arg);
};
return exports;
}());