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:
@@ -17,12 +17,11 @@ var Whisper = Whisper || {};
|
||||
|
||||
(function () {
|
||||
'use strict';
|
||||
Whisper.PhoneInputView = Backbone.View.extend({
|
||||
Whisper.PhoneInputView = Whisper.View.extend({
|
||||
tagName: 'div',
|
||||
className: 'phone-input',
|
||||
template: $('#phone-number').html(),
|
||||
initialize: function() {
|
||||
this.template = $('#phone-number').html();
|
||||
Mustache.parse(this.template);
|
||||
this.render();
|
||||
},
|
||||
|
||||
|
Reference in New Issue
Block a user