DEV: add `emoji` handlebars helper (#17449)
This commit is contained in:
parent
f48a1ec648
commit
075d6b83f4
|
@ -0,0 +1,11 @@
|
||||||
|
import { emojiUnescape } from "discourse/lib/text";
|
||||||
|
import { escapeExpression } from "discourse/lib/utilities";
|
||||||
|
import { htmlSafe } from "@ember/template";
|
||||||
|
import { helper } from "@ember/component/helper";
|
||||||
|
|
||||||
|
function emoji(code, options) {
|
||||||
|
const escaped = escapeExpression(`:${code}:`);
|
||||||
|
return htmlSafe(emojiUnescape(escaped, options));
|
||||||
|
}
|
||||||
|
|
||||||
|
export default helper(emoji);
|
|
@ -0,0 +1,14 @@
|
||||||
|
import { module, test } from "qunit";
|
||||||
|
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
||||||
|
import { render } from "@ember/test-helpers";
|
||||||
|
import { exists } from "discourse/tests/helpers/qunit-helpers";
|
||||||
|
import { hbs } from "ember-cli-htmlbars";
|
||||||
|
|
||||||
|
module("Integration | Helper | emoji", function (hooks) {
|
||||||
|
setupRenderingTest(hooks);
|
||||||
|
|
||||||
|
test("it renders", async function (assert) {
|
||||||
|
await render(hbs`{{emoji "tada"}}`);
|
||||||
|
assert.ok(exists(`.emoji[title="tada"]`));
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in New Issue