Vue.component('message', { template: '#message_template', data() { return {}; }, computed: { textEscaped() { let s = ''; if (this.template) { s = this.colorize(this.template); } else { s = this.colorize(this.templates[this.templateId]); } return s.replace(/{(\d+)}/g, (match, number) => { const argEscaped = this.args[number] != undefined ? this.escape(this.args[number]) : match if (number == 0 && this.color) { //color is deprecated, use templates or ^1 etc. return this.colorizeOld(argEscaped); } return argEscaped; }); }, }, methods: { colorizeOld(str) { return `${str}` }, colorize(str) { const s = "" + (str.replace(/\^([0-9]+)/g, (str, color) => ``)) + ""; return s.replace(/]*><\/span[^>]*>/g, ''); }, escape(unsafe) { return String(unsafe) .replace(/&/g, '&') .replace(//g, '>') .replace(/"/g, '"') .replace(/'/g, '''); }, }, props: { templates: { type: Object, }, args: { type: Array, }, template: { type: String, default: null, }, templateId: { type: String, default: CONFIG.defaultTemplateId, }, multiline: { type: Boolean, default: false, }, color: { //deprecated type: Array, default: false, }, }, });