mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 13:03:29 +00:00
Use compiled.js in dev environments.
Make our dev setup more similar to prod by using compiled.js, instead of AJAX-ing templates on the fly and compiling them with non-node code. This will make our dev environment more consistent with prod (to avoid surprising bugs), plus it should be faster (fewer AJAX calls). This change also means we don't have to keep two copies of static/third/handlebars/handlebars.js around. (imported from commit d8d584b9aa13adcdcce7e424033610d77d2df79b)
This commit is contained in:
committed by
Waseem Daher
parent
1ad82b1f70
commit
2504baf783
@@ -3,25 +3,14 @@ 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);
|
||||
}
|
||||
});
|
||||
if (Handlebars.templates === undefined) {
|
||||
throw "Cannot find compiled templates!";
|
||||
}
|
||||
|
||||
// The templates should be compiled into compiled.js. In
|
||||
// prod we build compiled.js as part of the deployment process,
|
||||
// and for devs we have run_dev.py build compiled.js when templates
|
||||
// change.
|
||||
return Handlebars.templates[name](arg);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user