Make all mustache templates available as partials
// FREEBIE
This commit is contained in:
parent
9566f10ca4
commit
5d9965a60e
1 changed files with 12 additions and 4 deletions
|
@ -26,9 +26,7 @@
|
||||||
return _.result(this.model, 'attributes', {});
|
return _.result(this.model, 'attributes', {});
|
||||||
},
|
},
|
||||||
render_partials: function() {
|
render_partials: function() {
|
||||||
return {
|
return Whisper.View.Templates;
|
||||||
avatar: this.avatar_template
|
|
||||||
};
|
|
||||||
},
|
},
|
||||||
render: function() {
|
render: function() {
|
||||||
var attrs = _.result(this, 'render_attributes', {});
|
var attrs = _.result(this, 'render_attributes', {});
|
||||||
|
@ -37,7 +35,6 @@
|
||||||
this.$el.html(Mustache.render(template, attrs, partials));
|
this.$el.html(Mustache.render(template, attrs, partials));
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
avatar_template: $('#avatar').html(),
|
|
||||||
confirm: function(message) {
|
confirm: function(message) {
|
||||||
return new Promise(function(resolve, reject) {
|
return new Promise(function(resolve, reject) {
|
||||||
var dialog = new Whisper.ConfirmationDialogView({
|
var dialog = new Whisper.ConfirmationDialogView({
|
||||||
|
@ -48,5 +45,16 @@
|
||||||
this.$el.append(dialog.el);
|
this.$el.append(dialog.el);
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
}
|
}
|
||||||
|
},{
|
||||||
|
// Class attributes
|
||||||
|
Templates: (function() {
|
||||||
|
var templates = {};
|
||||||
|
$('script[type="text/x-tmpl-mustache"]').each(function(i, el) {
|
||||||
|
var $el = $(el);
|
||||||
|
var id = $el.attr('id').replace('-','_');
|
||||||
|
templates[id] = $el.html();
|
||||||
|
});
|
||||||
|
return templates;
|
||||||
|
}())
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
|
|
Loading…
Reference in a new issue