DEV: Remove `Handlebars.Utils.escapeExpression` usage

DEV: Remove Handlebars.Utils.escapeExpression usage

diff --git a/app/assets/javascripts/admin/controllers/modals/admin-badge-preview.js b/app/assets/javascripts/admin/controllers/modals/admin-badge-preview.js
index 84325f9..c5baa8e 100644
--- a/app/assets/javascripts/admin/controllers/modals/admin-badge-preview.js
+++ b/app/assets/javascripts/admin/controllers/modals/admin-badge-preview.js
@@ -42,7 +42,7 @@ export default Controller.extend({
     if (grant.post_id) {
       i18nKey += "_post";
       i18nParams.link = `<a href="/p/${grant.post_id}" data-auto-route="true">
-        ${Handlebars.Utils.escapeExpression(grant.title)}
+        ${escapeExpression(grant.title)}
       </a>`;
     }
 
diff --git a/app/assets/javascripts/discourse/app/helpers/application.js b/app/assets/javascripts/discourse/app/helpers/application.js
index 27727c1..8ebdb1c 100644
--- a/app/assets/javascripts/discourse/app/helpers/application.js
+++ b/app/assets/javascripts/discourse/app/helpers/application.js
@@ -5,6 +5,7 @@ import {
   number
 } from "discourse/lib/formatter";
 import { htmlSafe } from "@ember/template";
+import { escapeExpression } from "discourse/lib/utilities";
 
 registerUnbound("raw-date", dt => htmlSafe(longDate(new Date(dt))));
 
@@ -37,10 +38,10 @@ registerUnbound("number", (orig, params) => {
   // Round off the thousands to one decimal place
   const n = number(orig);
   if (n.toString() !== title.toString() && addTitle) {
-    result += " title='" + Handlebars.Utils.escapeExpression(title) + "'";
+    result += " title='" + escapeExpression(title) + "'";
   }
   if (params.ariaLabel) {
-    const ariaLabel = Handlebars.Utils.escapeExpression(params.ariaLabel);
+    const ariaLabel = escapeExpression(params.ariaLabel);
     result += ` aria-label='${ariaLabel}'`;
   }
 
diff --git a/app/assets/javascripts/discourse/app/helpers/category-link.js b/app/assets/javascripts/discourse/app/helpers/category-link.js
index 5199eda..d214112 100644
--- a/app/assets/javascripts/discourse/app/helpers/category-link.js
+++ b/app/assets/javascripts/discourse/app/helpers/category-link.js
@@ -4,8 +4,8 @@ import { isRTL } from "discourse/lib/text-direction";
 import { iconHTML } from "discourse-common/lib/icon-library";
 import Category from "discourse/models/category";
 import Site from "discourse/models/site";
+import { escapeExpression } from "discourse/lib/utilities";
 
-let escapeExpression = Handlebars.Utils.escapeExpression;
 let _renderer = defaultCategoryLinkRenderer;
 
 export function replaceCategoryLinkRenderer(fn) {
diff --git a/app/assets/javascripts/discourse/app/lib/plugin-api.js b/app/assets/javascripts/discourse/app/lib/plugin-api.js
index 7188000..3d9dcd4 100644
--- a/app/assets/javascripts/discourse/app/lib/plugin-api.js
+++ b/app/assets/javascripts/discourse/app/lib/plugin-api.js
@@ -972,7 +972,7 @@ class PluginApi {
    * Example:
    *
    * function testTagRenderer(tag, params) {
-   *   const visibleName = Handlebars.Utils.escapeExpression(tag);
+   *   const visibleName = escapeExpression(tag);
    *   return `testing: ${visibleName}`;
    * }
    * api.replaceTagRenderer(testTagRenderer);
diff --git a/app/assets/javascripts/discourse/app/lib/render-tag.js b/app/assets/javascripts/discourse/app/lib/render-tag.js
index f9230f0..f1882a3 100644
--- a/app/assets/javascripts/discourse/app/lib/render-tag.js
+++ b/app/assets/javascripts/discourse/app/lib/render-tag.js
@@ -1,4 +1,5 @@
 import User from "discourse/models/user";
+import { escapeExpression } from "discourse/lib/utilities";
 
 let _renderer = defaultRenderTag;
 
@@ -8,7 +9,7 @@ export function replaceTagRenderer(fn) {
 
 export function defaultRenderTag(tag, params) {
   params = params || {};
-  const visibleName = Handlebars.Utils.escapeExpression(tag);
+  const visibleName = escapeExpression(tag);
   tag = visibleName.toLowerCase();
   const classes = ["discourse-tag"];
   const tagName = params.tagName || "a";
diff --git a/app/assets/javascripts/discourse/app/lib/search.js b/app/assets/javascripts/discourse/app/lib/search.js
index d6c76dd..f057425 100644
--- a/app/assets/javascripts/discourse/app/lib/search.js
+++ b/app/assets/javascripts/discourse/app/lib/search.js
@@ -10,6 +10,7 @@ import { emojiUnescape } from "discourse/lib/text";
 import User from "discourse/models/user";
 import Post from "discourse/models/post";
 import Topic from "discourse/models/topic";
+import { escapeExpression } from "discourse/lib/utilities";
 
 export function translateResults(results, opts) {
   opts = opts || {};
@@ -50,17 +51,13 @@ export function translateResults(results, opts) {
 
   results.groups = results.groups
     .map(group => {
-      const name = Handlebars.Utils.escapeExpression(group.name);
-      const fullName = Handlebars.Utils.escapeExpression(
-        group.full_name || group.display_name
-      );
+      const name = escapeExpression(group.name);
+      const fullName = escapeExpression(group.full_name || group.display_name);
       const flairUrl = isEmpty(group.flair_url)
         ? null
-        : Handlebars.Utils.escapeExpression(group.flair_url);
-      const flairColor = Handlebars.Utils.escapeExpression(group.flair_color);
-      const flairBgColor = Handlebars.Utils.escapeExpression(
-        group.flair_bg_color
-      );
+        : escapeExpression(group.flair_url);
+      const flairColor = escapeExpression(group.flair_color);
+      const flairBgColor = escapeExpression(group.flair_bg_color);
 
       return {
         id: group.id,
@@ -76,7 +73,7 @@ export function translateResults(results, opts) {
 
   results.tags = results.tags
     .map(function(tag) {
-      const tagName = Handlebars.Utils.escapeExpression(tag.name);
+      const tagName = escapeExpression(tag.name);
       return EmberObject.create({
         id: tagName,
         url: Discourse.getURL("/tag/" + tagName)
diff --git a/app/assets/javascripts/discourse/app/mixins/card-contents-base.js b/app/assets/javascripts/discourse/app/mixins/card-contents-base.js
index b1aeb85..59464e1 100644
--- a/app/assets/javascripts/discourse/app/mixins/card-contents-base.js
+++ b/app/assets/javascripts/discourse/app/mixins/card-contents-base.js
@@ -4,6 +4,7 @@ import { wantsNewWindow } from "discourse/lib/intercept-click";
 import afterTransition from "discourse/lib/after-transition";
 import DiscourseURL from "discourse/lib/url";
 import Mixin from "@ember/object/mixin";
+import { escapeExpression } from "discourse/lib/utilities";
 
 export default Mixin.create({
   elementId: null, //click detection added for data-{elementId}
@@ -27,7 +28,7 @@ export default Mixin.create({
       return false;
     }
 
-    username = Ember.Handlebars.Utils.escapeExpression(username.toString());
+    username = escapeExpression(username.toString());
 
     // Don't show if nested
     if ($target.parents(".card-content").length) {
diff --git a/app/assets/javascripts/discourse/app/models/user-drafts-stream.js b/app/assets/javascripts/discourse/app/models/user-drafts-stream.js
index 07529f6..ddf1c83 100644
--- a/app/assets/javascripts/discourse/app/models/user-drafts-stream.js
+++ b/app/assets/javascripts/discourse/app/models/user-drafts-stream.js
@@ -10,6 +10,7 @@ import {
   NEW_TOPIC_KEY,
   NEW_PRIVATE_MESSAGE_KEY
 } from "discourse/models/composer";
+import { escapeExpression } from "discourse/lib/utilities";
 
 export default RestModel.extend({
   loaded: false,
@@ -81,9 +82,7 @@ export default RestModel.extend({
             ) {
               draft.title = draftData.title;
             }
-            draft.title = emojiUnescape(
-              Handlebars.Utils.escapeExpression(draft.title)
-            );
+            draft.title = emojiUnescape(escapeExpression(draft.title));
             if (draft.category_id) {
               draft.category =
                 this.site.categories.findBy("id", draft.category_id) || null;
diff --git a/app/assets/javascripts/discourse/app/models/user-stream.js b/app/assets/javascripts/discourse/app/models/user-stream.js

[... diff too long, it was truncated ...]

GitHub sha: 03815f97