Skip to content

Commit 0e06722

Browse files
authored
Merge pull request #299 from davidtaylorhq/remove-handlebars
DEV: Remove Handlebars dependency
2 parents d2ff1b5 + 6b8db71 commit 0e06722

File tree

2 files changed

+13
-16
lines changed

2 files changed

+13
-16
lines changed

Diff for: assets/javascripts/discourse/components/custom-user-selector.js

+8-11
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
11
import { isEmpty } from "@ember/utils";
2-
import Handlebars from "handlebars";
32
import $ from "jquery";
43
import TextField from "discourse/components/text-field";
54
import { renderAvatar } from "discourse/helpers/user-avatar";
5+
import { default as computed, observes } from "discourse/lib/decorators";
66
import userSearch from "discourse/lib/user-search";
7-
import {
8-
default as computed,
9-
observes,
10-
} from "discourse-common/utils/decorators";
11-
import I18n from "I18n";
7+
import { escapeExpression } from "discourse/lib/utilities";
8+
import { i18n } from "discourse-i18n";
129

1310
const template = function (params) {
1411
const options = params.options;
@@ -17,11 +14,11 @@ const template = function (params) {
1714
if (options.users) {
1815
html += "<ul>";
1916
options.users.forEach((u) => {
20-
html += `<li><a href title="${u.name}">`;
17+
html += `<li><a href title="${escapeExpression(u.name)}">`;
2118
html += renderAvatar(u, { imageSize: "tiny" });
22-
html += `<span class='username'>${u.username}</span>`;
19+
html += `<span class='username'>${escapeExpression(u.username)}</span>`;
2320
if (u.name) {
24-
html += `<span class='name'>${u.name}</span>`;
21+
html += `<span class='name'>${escapeExpression(u.name)}</span>`;
2522
}
2623
html += `</a></li>`;
2724
});
@@ -30,7 +27,7 @@ const template = function (params) {
3027

3128
html += "</div>";
3229

33-
return new Handlebars.SafeString(html).string;
30+
return html;
3431
};
3532

3633
export default TextField.extend({
@@ -42,7 +39,7 @@ export default TextField.extend({
4239

4340
@computed("placeholderKey")
4441
placeholder(placeholderKey) {
45-
return placeholderKey ? I18n.t(placeholderKey) : "";
42+
return placeholderKey ? i18n(placeholderKey) : "";
4643
},
4744

4845
@observes("usernames")
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
import Handlebars from "handlebars";
2-
import I18n from "I18n";
1+
import { htmlSafe } from "@ember/template";
2+
import { i18n } from "discourse-i18n";
33

44
export default function wizardCharCounter(body, maxLength) {
55
let bodyLength = body ? body.length : 0;
66
let finalString;
77

88
if (maxLength) {
99
let isOverMax = bodyLength > maxLength ? "true" : "false";
10-
finalString = `<div class="body-length" data-length=${bodyLength} data-over-max=${isOverMax}>${bodyLength} / ${I18n.t(
10+
finalString = `<div class="body-length" data-length=${bodyLength} data-over-max=${isOverMax}>${bodyLength} / ${i18n(
1111
"wizard.x_characters",
1212
{ count: parseInt(maxLength, 10) }
1313
)}</div>`;
1414
} else {
15-
finalString = `<div class="body-length">${I18n.t("wizard.x_characters", {
15+
finalString = `<div class="body-length">${i18n("wizard.x_characters", {
1616
count: parseInt(bodyLength, 10),
1717
})}</div>`;
1818
}
1919

20-
return new Handlebars.SafeString(finalString);
20+
return htmlSafe(finalString);
2121
}

0 commit comments

Comments
 (0)