From d6ef4fc5ca45ce657e966611e705ab45b48e4882 Mon Sep 17 00:00:00 2001 From: JC Brand Date: Fri, 1 Jul 2016 14:27:26 +0200 Subject: [PATCH] Add method hook for adding more attrs to send to the message template --- src/converse-chatview.js | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/converse-chatview.js b/src/converse-chatview.js index 8a7e25910..aefc8dbe7 100644 --- a/src/converse-chatview.js +++ b/src/converse-chatview.js @@ -254,6 +254,12 @@ )(this.renderMessage(attrs)); }, + getExtraMessageTemplateAttributes: function (attrs) { + // Provides a hook for sending more attributes to the + // message template. + return {}; + }, + renderMessage: function (attrs) { /* Renders a chat message based on the passed in attributes. * @@ -286,15 +292,17 @@ // are mentioned. extra_classes += ' mentioned'; } - return $(template({ - msgid: attrs.msgid, - 'sender': attrs.sender, - 'time': msg_time.format('hh:mm'), - 'isodate': msg_time.format(), - 'username': username, - 'message': '', - 'extra_classes': extra_classes - })).children('.chat-msg-content').first().text(text) + return $(template( + _.extend(this.getExtraMessageTemplateAttributes(attrs), { + 'msgid': attrs.msgid, + 'sender': attrs.sender, + 'time': msg_time.format('hh:mm'), + 'isodate': msg_time.format(), + 'username': username, + 'message': '', + 'extra_classes': extra_classes + }) + )).children('.chat-msg-content').first().text(text) .addHyperlinks() .addEmoticons(converse.visible_toolbar_buttons.emoticons).parent(); },