A platform for community discussion. Free, open, simple.
DEV: Remove global Handlebars
Robin Wardf182e61def80
diff --git a/.eslintignore b/.eslintignoreindex 6676467368f..e877e0062b6 100644--- a/.eslintignore+++ b/.eslintignore@@ -13,3 +13,5 @@ vendor/test/javascripts/test_helper.jstest/javascripts/fixturestest/javascripts/helpers/assertions.js+node_modules/+dist/diff --git a/app/assets/javascripts/discourse/app/controllers/composer.js b/app/assets/javascripts/discourse/app/controllers/composer.jsindex 9d04586c11f..9ed71e654a3 100644--- a/app/assets/javascripts/discourse/app/controllers/composer.js+++ b/app/assets/javascripts/discourse/app/controllers/composer.js@@ -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});diff --git a/app/assets/javascripts/discourse/app/controllers/topic.js b/app/assets/javascripts/discourse/app/controllers/topic.jsindex a49cbaf2e24..3ec58a55566 100644--- a/app/assets/javascripts/discourse/app/controllers/topic.js+++ b/app/assets/javascripts/discourse/app/controllers/topic.js@@ -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", {diff --git a/app/assets/javascripts/discourse/app/initializers/auto-load-modules.js b/app/assets/javascripts/discourse/app/initializers/auto-load-modules.jsindex 3e1505a5dda..bea9bf47950 100644--- a/app/assets/javascripts/discourse/app/initializers/auto-load-modules.js+++ b/app/assets/javascripts/discourse/app/initializers/auto-load-modules.js@@ -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 => {diff --git a/app/assets/javascripts/discourse/app/initializers/live-development.js b/app/assets/javascripts/discourse/app/initializers/live-development.jsindex 38afdbc9b78..fe3d59875bb 100644--- a/app/assets/javascripts/discourse/app/initializers/live-development.js+++ b/app/assets/javascripts/discourse/app/initializers/live-development.js@@ -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 {diff --git a/app/assets/javascripts/handlebars-shim.js b/app/assets/javascripts/handlebars-shim.jsindex e01e17c49ee..85a73c56a8c 100644--- a/app/assets/javascripts/handlebars-shim.js+++ b/app/assets/javascripts/handlebars-shim.js@@ -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-textif (typeof Handlebars !== "undefined") {+ // eslint-disable-next-line__exports__.default = Handlebars;}});++ define("handlebars-compiler", ["exports"], function(__exports__) {+ // eslint-disable-next-line+ __exports__.default = Handlebars.compile;+ });}diff --git a/package.json b/package.jsonindex 0a745f479b2..95dc2e4d054 100644--- a/package.json+++ b/package.json@@ -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",diff --git a/test/javascripts/acceptance/raw-plugin-outlet-test.js b/test/javascripts/acceptance/raw-plugin-outlet-test.jsindex 62ea96028f6..8f104ce37b6 100644--- a/test/javascripts/acceptance/raw-plugin-outlet-test.js+++ b/test/javascripts/acceptance/raw-plugin-outlet-test.js@@ -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>`);},diff --git a/yarn.lock b/yarn.lockindex 4383920b0fc..742a3bd36e8 100644--- a/yarn.lock+++ b/yarn.lock@@ -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=- 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==+ 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"