From 1442774856841be7830a131153931252fac59293 Mon Sep 17 00:00:00 2001 From: JC Brand Date: Fri, 21 Sep 2012 16:42:03 +0200 Subject: [PATCH] Use Mustache style variable interpolation. --- converse.js | 49 +++++++++++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 20 deletions(-) diff --git a/converse.js b/converse.js index 74e8e1afb..2624d3df9 100644 --- a/converse.js +++ b/converse.js @@ -17,6 +17,11 @@ 'burry.js/burry' ], function (Burry) { var store = new Burry.Store('collective.xmpp.chat'); + // Use Mustache style syntax for variable interpolation + _.templateSettings = { + evaluate : /\{\[([\s\S]+?)\]\}/g, + interpolate : /\{\{([\s\S]+?)\}\}/g + }; _.str = require('underscore.string'); return factory(jarnxmpp, jQuery, store, _, console); } @@ -24,6 +29,10 @@ } else { // Browser globals var store = new Burry.Store('collective.xmpp.chat'); + _.templateSettings = { + evaluate : /\{\[([\s\S]+?)\]\}/g, + interpolate : /\{\{([\s\S]+?)\}\}/g + }; root.xmppchat = factory(jarnxmpp, jQuery, store, _, console || {log: function(){}}); } }(this, function (jarnxmpp, $, store, _, console) { @@ -121,15 +130,15 @@ }, message_template: _.template( - '
' + - '<%=time%> <%=username%>: ' + - '<%=message%>' + + '
' + + '{{time}} {{username}}: ' + + '{{message}}' + '
'), action_template: _.template( - '
' + - '<%=time%>: ' + - '<%=message%>' + + '
' + + '{{time}}: ' + + '{{message}}' + '
'), appendMessage: function (message) { @@ -404,7 +413,7 @@ template: _.template( '
' + - '
<%= fullname %>
' + + '
{{ fullname }}
' + 'X' + '

' + '

' + @@ -502,8 +511,8 @@ }, room_template: _.template( '
' + - '' + - '<%=name%>
'), + '' + + '{{name}}'), initialize: function () { this.on('update-rooms-list', function (ev) { @@ -662,7 +671,7 @@ template: _.template( '
' + - '
<%= name %>
' + + '
{{ name }}
' + 'X' + '

' + '

' + @@ -691,7 +700,7 @@ }, onLeave: function () { - var controlboxview = xmppchat.chatboxesview.views['controlbox']; + var controlboxview = xmppchat.chatboxesview.views.controlbox; if (controlboxview) { controlboxview.roomspanel.trigger('update-rooms-list'); } @@ -990,14 +999,14 @@ }, template: _.template( - '<%= fullname %>' + + '{{ fullname }}' + ''), pending_template: _.template( - '<%= fullname %>' + + '{{ fullname }}' + ''), - request_template: _.template('<%= fullname %>' + + request_template: _.template('{{ fullname }}' + '' + '' + ''), status_template: _.template( ''), @@ -1420,9 +1429,9 @@ option_template: _.template( '
  • ' + - '' + - '<%= text %>' + - '<%= value %>' + + '' + + '{{ text }}' + + '{{ value }}' + '' + '
  • '),