DEV: Remove global Handlebars

This commit is contained in:
Robin Ward 2020-05-01 14:11:45 -04:00
parent 85605efe84
commit f182e61def
9 changed files with 20 additions and 8 deletions

View File

@ -13,3 +13,5 @@ vendor/
test/javascripts/test_helper.js
test/javascripts/fixtures
test/javascripts/helpers/assertions.js
node_modules/
dist/

View File

@ -352,7 +352,7 @@ export default Controller.extend({
if (!url || !topicTitle) return;
url = `${location.protocol}//${location.host}${url}`;
const link = `[${Handlebars.escapeExpression(topicTitle)}](${url})`;
const link = `[${escapeExpression(topicTitle)}](${url})`;
const continueDiscussion = I18n.t("post.continue_discussion", {
postLink: link
});

View File

@ -21,6 +21,7 @@ import { userPath } from "discourse/lib/url";
import showModal from "discourse/lib/show-modal";
import TopicTimer from "discourse/models/topic-timer";
import { Promise } from "rsvp";
import { escapeExpression } from "discourse/lib/utilities";
let customPostMessageCallbacks = {};
@ -976,7 +977,7 @@ export default Controller.extend(bufferedProperty("model"), {
}
composerController.open(options).then(() => {
const title = Handlebars.escapeExpression(this.model.title);
const title = escapeExpression(this.model.title);
const postUrl = `${location.protocol}//${location.host}${post.url}`;
const postLink = `[${title}](${postUrl})`;
const text = `${I18n.t("post.continue_discussion", {

View File

@ -1,6 +1,7 @@
import { registerHelpers } from "discourse-common/lib/helpers";
import RawHandlebars from "discourse-common/lib/raw-handlebars";
import { registerRawHelpers } from "discourse-common/lib/raw-handlebars-helpers";
import Handlebars from "handlebars";
export function autoLoadModules(container, registry) {
Object.keys(requirejs.entries).forEach(entry => {

View File

@ -1,6 +1,7 @@
import DiscourseURL from "discourse/lib/url";
import { currentThemeIds, refreshCSS } from "discourse/lib/theme-selector";
import ENV from "discourse-common/config/environment";
import Handlebars from "handlebars";
// Use the message bus for live reloading of components for faster development.
export default {

View File

@ -3,7 +3,13 @@ if (typeof define !== "undefined") {
define("handlebars", ["exports"], function(__exports__) {
// It might not be defined server side, which is OK for pretty-text
if (typeof Handlebars !== "undefined") {
// eslint-disable-next-line
__exports__.default = Handlebars;
}
});
define("handlebars-compiler", ["exports"], function(__exports__) {
// eslint-disable-next-line
__exports__.default = Handlebars.compile;
});
}

View File

@ -45,7 +45,7 @@
"chrome-launcher": "^0.12.0",
"chrome-remote-interface": "^0.25",
"ember-template-lint": "^2.5.2",
"eslint-config-discourse": "1.1.0",
"eslint-config-discourse": "1.1.1",
"eslint-plugin-discourse-ember": "0.0.3",
"lodash-cli": "https://github.com/lodash-archive/lodash-cli.git",
"pretender": "^1.6",

View File

@ -1,10 +1,11 @@
import { acceptance } from "helpers/qunit-helpers";
import compile from "handlebars-compiler";
const CONNECTOR =
"javascripts/raw-test/connectors/topic-list-before-status/lala";
acceptance("Raw Plugin Outlet", {
beforeEach() {
Discourse.RAW_TEMPLATES[CONNECTOR] = Handlebars.compile(
Discourse.RAW_TEMPLATES[CONNECTOR] = compile(
`<span class='topic-lala'>{{context.topic.id}}</span>`
);
},

View File

@ -969,10 +969,10 @@ escape-string-regexp@^1.0.2, escape-string-regexp@^1.0.5:
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4"
integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=
eslint-config-discourse@1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/eslint-config-discourse/-/eslint-config-discourse-1.1.0.tgz#1f2b1ffd6064c579bc74eca63420bd3cd5732950"
integrity sha512-y2osWnbIi/CS2hDm61K6vdYA5vEuFJRetI2UFlEo8rQCx2t46XUd+FkgAvBy0nzLSm7ELBKru5qYKveKFF6eAg==
eslint-config-discourse@1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/eslint-config-discourse/-/eslint-config-discourse-1.1.1.tgz#8a7f7f6f1a388b0e88f5b79145ae2a8b4a13e3d4"
integrity sha512-b3dp9DOcXYWkPQpXms/bMDy0Scb6DO/nZAAsl5I9yTNhtkx96zZMTp9QEyC8QaCXOTUpIXEE6V+Mpyjtsk3gWg==
dependencies:
babel-eslint "^8.2"
eslint "^4.19"