mirror of https://github.com/zulip/zulip.git
js: Use Handlebars as a module.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
46e80cdd3a
commit
226598edc4
|
@ -99,7 +99,6 @@
|
|||
"$": false,
|
||||
"FetchStatus": false,
|
||||
"Filter": false,
|
||||
"Handlebars": false,
|
||||
"LightboxCanvas": false,
|
||||
"ListCursor": false,
|
||||
"MessageListData": false,
|
||||
|
|
|
@ -75,7 +75,6 @@ set_global("stream_popover", _stream_popover);
|
|||
set_global("ui", _ui);
|
||||
|
||||
zrequire("compose_fade");
|
||||
set_global("Handlebars", global.make_handlebars());
|
||||
zrequire("unread");
|
||||
zrequire("hash_util");
|
||||
zrequire("narrow");
|
||||
|
|
|
@ -67,7 +67,6 @@ zrequire("compose_ui");
|
|||
const util = zrequire("util");
|
||||
zrequire("rtl");
|
||||
zrequire("common");
|
||||
set_global("Handlebars", global.make_handlebars());
|
||||
zrequire("stream_data");
|
||||
zrequire("compose_state");
|
||||
zrequire("people");
|
||||
|
|
|
@ -2,7 +2,6 @@ const emoji = zrequire("emoji", "shared/js/emoji");
|
|||
const typeahead = zrequire("typeahead", "shared/js/typeahead");
|
||||
zrequire("compose_state");
|
||||
zrequire("pm_conversations");
|
||||
set_global("Handlebars", global.make_handlebars());
|
||||
zrequire("templates");
|
||||
zrequire("typeahead_helper");
|
||||
zrequire("people");
|
||||
|
|
|
@ -5,7 +5,6 @@ set_global("$", global.make_zjquery());
|
|||
zrequire("localstorage");
|
||||
zrequire("drafts");
|
||||
zrequire("timerender");
|
||||
set_global("Handlebars", global.make_handlebars());
|
||||
zrequire("stream_color");
|
||||
zrequire("colorspace");
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
zrequire("unread");
|
||||
zrequire("stream_data");
|
||||
zrequire("people");
|
||||
set_global("Handlebars", global.make_handlebars());
|
||||
global.stub_out_jquery();
|
||||
set_global("$", global.make_zjquery());
|
||||
zrequire("message_util", "js/message_util");
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
set_global("Handlebars", global.make_handlebars());
|
||||
zrequire("templates");
|
||||
|
||||
// We download our translations in `page_params` (which
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
set_global("$", global.make_zjquery());
|
||||
zrequire("input_pill");
|
||||
|
||||
set_global("Handlebars", global.make_handlebars());
|
||||
zrequire("templates");
|
||||
|
||||
set_global("document", {});
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
zrequire("search_pill");
|
||||
zrequire("input_pill");
|
||||
zrequire("Filter", "js/filter");
|
||||
set_global("Handlebars", global.make_handlebars());
|
||||
|
||||
const is_starred_item = {
|
||||
display_value: "is:starred",
|
||||
|
|
|
@ -13,7 +13,6 @@ page_params.realm_email_address_visibility =
|
|||
const huddle_data = zrequire("huddle_data");
|
||||
|
||||
zrequire("typeahead_helper");
|
||||
set_global("Handlebars", global.make_handlebars());
|
||||
zrequire("Filter", "js/filter");
|
||||
zrequire("narrow_state");
|
||||
zrequire("stream_data");
|
||||
|
|
|
@ -12,7 +12,6 @@ page_params.realm_email_address_visibility =
|
|||
const huddle_data = zrequire("huddle_data");
|
||||
|
||||
zrequire("typeahead_helper");
|
||||
set_global("Handlebars", global.make_handlebars());
|
||||
zrequire("Filter", "js/filter");
|
||||
zrequire("narrow_state");
|
||||
zrequire("stream_data");
|
||||
|
|
|
@ -5,7 +5,6 @@ const settings_config = zrequire("settings_config");
|
|||
page_params.realm_email_address_visibility =
|
||||
settings_config.email_address_visibility_values.admins_only.code;
|
||||
|
||||
set_global("Handlebars", global.make_handlebars());
|
||||
zrequire("recent_senders");
|
||||
zrequire("pm_conversations");
|
||||
zrequire("people");
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
|
||||
const Handlebars = require("handlebars/dist/cjs/handlebars.js");
|
||||
const Handlebars = require("handlebars");
|
||||
const {SourceMapConsumer, SourceNode} = require("source-map");
|
||||
|
||||
const templates_path = path.resolve(__dirname, "../../static/templates");
|
||||
|
||||
exports.make_handlebars = () => Handlebars.create();
|
||||
|
||||
exports.stub_templates = (stub) => {
|
||||
window.template_stub = stub;
|
||||
};
|
||||
|
@ -34,18 +32,16 @@ require.extensions[".hbs"] = (module, filename) => {
|
|||
const pc = hb.precompile(code, {preventIndent: true, srcName: filename});
|
||||
const node = new SourceNode();
|
||||
node.add([
|
||||
"let hb, template;\n",
|
||||
'const Handlebars = require("handlebars/runtime");\n',
|
||||
"const template = Handlebars.template(",
|
||||
SourceNode.fromStringWithSourceMap(pc.code, new SourceMapConsumer(pc.map)),
|
||||
");\n",
|
||||
"module.exports = (...args) => {\n",
|
||||
" if (window.template_stub !== undefined) {\n",
|
||||
" return window.template_stub(",
|
||||
JSON.stringify(name),
|
||||
", ...args);\n",
|
||||
" }\n",
|
||||
" if (hb !== Handlebars) {\n",
|
||||
" template = (hb = Handlebars).template(",
|
||||
SourceNode.fromStringWithSourceMap(pc.code, new SourceMapConsumer(pc.map)),
|
||||
");\n",
|
||||
" }\n",
|
||||
" return template(...args);\n",
|
||||
"};\n",
|
||||
]);
|
||||
|
|
|
@ -2,6 +2,7 @@ const fs = require("fs");
|
|||
const Module = require("module");
|
||||
const path = require("path");
|
||||
|
||||
const Handlebars = require("handlebars/runtime");
|
||||
const _ = require("lodash");
|
||||
|
||||
const finder = require("./finder.js");
|
||||
|
@ -57,7 +58,6 @@ global.with_stub = stub.with_stub;
|
|||
global.make_zjquery = zjquery.make_zjquery;
|
||||
|
||||
// Set up Handlebars
|
||||
global.make_handlebars = handlebars.make_handlebars;
|
||||
global.stub_templates = handlebars.stub_templates;
|
||||
|
||||
const noop = function () {};
|
||||
|
@ -136,6 +136,7 @@ try {
|
|||
}
|
||||
|
||||
namespace.restore();
|
||||
Handlebars.HandlebarsEnvironment();
|
||||
});
|
||||
} catch (e) {
|
||||
if (e.stack) {
|
||||
|
|
|
@ -7,7 +7,6 @@ import "jquery-caret-plugin/src/jquery.caret.js";
|
|||
import "../../third/jquery-idle/jquery.idle.js";
|
||||
import "spectrum-colorpicker";
|
||||
import "jquery-validation/dist/jquery.validate.js";
|
||||
import "handlebars/dist/cjs/handlebars.runtime.js";
|
||||
import "flatpickr/dist/flatpickr.js";
|
||||
import "flatpickr/dist/plugins/confirmDate/confirmDate.js";
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
const Handlebars = require("handlebars/runtime");
|
||||
|
||||
const render_compose_all_everyone = require("../templates/compose_all_everyone.hbs");
|
||||
const render_compose_announce = require("../templates/compose_announce.hbs");
|
||||
const render_compose_invite_users = require("../templates/compose_invite_users.hbs");
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
const Handlebars = require("handlebars/runtime");
|
||||
const XDate = require("xdate");
|
||||
|
||||
const render_draft_table_body = require("../templates/draft_table_body.hbs");
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
const Handlebars = require("handlebars/runtime");
|
||||
const _ = require("lodash");
|
||||
|
||||
const util = require("./util");
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
const Handlebars = require("handlebars/runtime");
|
||||
|
||||
const huddle_data = require("./huddle_data");
|
||||
const settings_data = require("./settings_data");
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
const Handlebars = require("handlebars/runtime");
|
||||
|
||||
const util = require("./util");
|
||||
|
||||
// Below, we register Zulip-specific extensions to the handlebars API.
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
const Handlebars = require("handlebars/runtime");
|
||||
|
||||
const pygments_data = require("../generated/pygments_data.json");
|
||||
const emoji = require("../shared/js/emoji");
|
||||
const typeahead = require("../shared/js/typeahead");
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
"archive": [
|
||||
"./static/js/bundles/portico.js",
|
||||
"katex/dist/katex.min.js",
|
||||
"handlebars/dist/cjs/handlebars.runtime.js",
|
||||
"./static/js/archive.js",
|
||||
"./static/js/colorspace.js",
|
||||
"./static/js/floating_recipient_bar.js",
|
||||
|
@ -28,7 +27,6 @@
|
|||
"./static/styles/portico/landing-page.scss",
|
||||
"./static/js/billing/helpers.js",
|
||||
"./static/js/billing/billing.js",
|
||||
"handlebars/dist/cjs/handlebars.runtime.js",
|
||||
"./static/js/templates.js",
|
||||
"./static/js/loading.js",
|
||||
"./static/styles/portico/billing.scss"
|
||||
|
@ -39,7 +37,6 @@
|
|||
"./static/styles/portico/landing-page.scss",
|
||||
"./static/js/billing/helpers.js",
|
||||
"./static/js/billing/upgrade.js",
|
||||
"handlebars/dist/cjs/handlebars.runtime.js",
|
||||
"./static/js/templates.js",
|
||||
"./static/js/loading.js",
|
||||
"./static/styles/portico/billing.scss"
|
||||
|
|
|
@ -246,7 +246,6 @@ export default (env?: string): webpack.Configuration[] => {
|
|||
{path: "./debug-require.js", name: "require"},
|
||||
{path: "../static/js/debug.js"},
|
||||
{path: "jquery/dist/jquery.js", name: ["$", "jQuery"]},
|
||||
{path: "handlebars/dist/cjs/handlebars.runtime.js", name: "Handlebars"},
|
||||
];
|
||||
config.module!.rules.unshift(...getExposeLoaders(exposeOptions));
|
||||
|
||||
|
|
Loading…
Reference in New Issue