DRY up a common view pattern
Define a Whisper.View base class that automatically parses and renders templates and attributes defined by the subclass. This saves us a good number of lines of code as well as some marginal memory overhead, since we are no longer saving per-instance copies of template strings.
This commit is contained in:
parent
7c9ad975bb
commit
1bb480f6ea
16 changed files with 109 additions and 60 deletions
|
@ -33,12 +33,9 @@
|
|||
});
|
||||
|
||||
|
||||
var ContentMessageView = Backbone.View.extend({
|
||||
var ContentMessageView = Whisper.View.extend({
|
||||
tagName: 'div',
|
||||
initialize: function() {
|
||||
this.template = $('#message').html();
|
||||
Mustache.parse(this.template);
|
||||
},
|
||||
template: $('#message').html(),
|
||||
className: function() {
|
||||
if (this.model.get('delivered')) { return 'delivered'; }
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue