Files
zulip/zephyr/static/js/templates.js
Keegan McAllister 17d5406b55 [manual] Fetch Handlebars templates using Ajax
...rather than embedding them into index.html.

This is only acceptable for dev, but the next commit adds an alternative
mechanism for prod.

There isn't actually a manual deployment step here.  However, this commit won't
work on staging / prod without the next one (since we don't serve
zephyr/static/templates in prod).

(imported from commit dce7ddfe89e07afc3a96699bb972fd124335aa05)
2013-04-02 14:43:58 -04:00

29 lines
797 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',
async: false,
success: function (data) {
Handlebars.templates[name] = Handlebars.compile(data);
}
});
}
return Handlebars.templates[name](arg);
};
return exports;
}());