diff --git a/src/headless/core.js b/src/headless/core.js index 2f49ea316..6d8f0c3f5 100644 --- a/src/headless/core.js +++ b/src/headless/core.js @@ -762,7 +762,7 @@ Object.assign(converse, { log, sizzle, sprintf, - stanza: u.stanza, + stx: u.stx, u, } }); diff --git a/src/headless/utils/core.js b/src/headless/utils/core.js index 10c543cd7..8c4e4698d 100644 --- a/src/headless/utils/core.js +++ b/src/headless/utils/core.js @@ -16,7 +16,7 @@ import { Strophe } from 'strophe.js/src/strophe.js'; import { getOpenPromise } from '@converse/openpromise'; import { setUserJID, } from '@converse/headless/utils/init.js'; import { settings_api } from '@converse/headless/shared/settings/api.js'; -import { stanza, toStanza } from './stanza.js'; +import { stx , toStanza } from './stanza.js'; export function isEmptyMessage (attrs) { if (attrs instanceof Model) { @@ -577,5 +577,5 @@ export default Object.assign({ isEmptyMessage, getUniqueId, toStanza, - stanza, + stx, }, u); diff --git a/src/headless/utils/stanza.js b/src/headless/utils/stanza.js index 154f3df37..33fba112c 100644 --- a/src/headless/utils/stanza.js +++ b/src/headless/utils/stanza.js @@ -11,7 +11,13 @@ export function toStanza (string) { } -export function stanza (strings, ...values) { +/** + * Tagged template literal function which can be used to generate XML stanzas. + * Similar to the `html` function, from Lit. + * + * @example stx`${show}` + */ +export function stx (strings, ...values) { return toStanza( strings.reduce((acc, str) => { const idx = strings.indexOf(str); diff --git a/src/plugins/muc-views/tests/corrections.js b/src/plugins/muc-views/tests/corrections.js index ebb17e6ff..670d67bcd 100644 --- a/src/plugins/muc-views/tests/corrections.js +++ b/src/plugins/muc-views/tests/corrections.js @@ -1,6 +1,6 @@ /*global mock, converse */ -const { $msg, $pres, Strophe, u, stanza } = converse.env; +const { $msg, $pres, Strophe, u, stx } = converse.env; describe("A Groupchat Message", function () { @@ -274,7 +274,7 @@ describe('A Groupchat Message XEP-0308 correction ', function () { const msg_id = u.getUniqueId(); await model.handleMessageStanza( - stanza` + stx`