From c81c324ef683d86ab898226ecd3ef9c168202b23 Mon Sep 17 00:00:00 2001 From: Jaseem Abid Date: Sat, 8 Feb 2014 00:22:04 +0530 Subject: [PATCH] Provide more useful scaffold --- templates/coffeescript/model.coffee | 10 ++++++++++ templates/coffeescript/requirejs/model.coffee | 12 +++++++++++- templates/coffeescript/requirejs/view.coffee | 16 +++++++++++++++- templates/coffeescript/view.coffee | 14 ++++++++++++++ templates/requirejs/model.js | 12 ++++++++++++ templates/requirejs/view.js | 18 +++++++++++++++++- templates/view.js | 18 +++++++++++++++++- 7 files changed, 96 insertions(+), 4 deletions(-) diff --git a/templates/coffeescript/model.coffee b/templates/coffeescript/model.coffee index f03d6a1..d4a82f9 100644 --- a/templates/coffeescript/model.coffee +++ b/templates/coffeescript/model.coffee @@ -1,3 +1,13 @@ 'use strict'; class <%= _.camelize(appname) %>.Models.<%= _.classify(name) %>Model extends Backbone.Model + url: '', + + initialize: () -> + + defaults: {} + + validate: (attrs, options) -> + + parse: (response, options) -> + response diff --git a/templates/coffeescript/requirejs/model.coffee b/templates/coffeescript/requirejs/model.coffee index 91eb58a..305cc83 100644 --- a/templates/coffeescript/requirejs/model.coffee +++ b/templates/coffeescript/requirejs/model.coffee @@ -4,4 +4,14 @@ define [ ], (_, Backbone) -> 'use strict'; - class <%= _.classify(name) %>Model extends Backbone.Model \ No newline at end of file + class <%= _.classify(name) %>Model extends Backbone.Model + url: '', + + initialize: () -> + + defaults: {} + + validate: (attrs, options) -> + + parse: (response, options) -> + response diff --git a/templates/coffeescript/requirejs/view.coffee b/templates/coffeescript/requirejs/view.coffee index 77bc301..48ade60 100644 --- a/templates/coffeescript/requirejs/view.coffee +++ b/templates/coffeescript/requirejs/view.coffee @@ -5,4 +5,18 @@ define [ 'templates' ], ($, _, Backbone, JST) -> class <%= _.classify(name) %>View extends Backbone.View - template: JST['<%= jst_path %>'] \ No newline at end of file + template: JST['<%= jst_path %>'] + + tagName: 'div' + + id: '' + + className: '' + + events: {} + + initialize: () -> + @listenTo @model, 'change', @render + + render: () -> + @$el.html @template(@model.toJSON()) diff --git a/templates/coffeescript/view.coffee b/templates/coffeescript/view.coffee index 7ba07b7..9fdda67 100644 --- a/templates/coffeescript/view.coffee +++ b/templates/coffeescript/view.coffee @@ -3,3 +3,17 @@ class <%= _.camelize(appname) %>.Views.<%= _.classify(name) %>View extends Backbone.View template: JST['<%= jst_path %>'] + + tagName: 'div' + + id: '' + + className: '' + + events: {} + + initialize: () -> + @listenTo @model, 'change', @render + + render: () -> + @$el.html @template(@model.toJSON()) diff --git a/templates/requirejs/model.js b/templates/requirejs/model.js index 8bf92a1..4d1c2e5 100644 --- a/templates/requirejs/model.js +++ b/templates/requirejs/model.js @@ -7,7 +7,19 @@ define([ 'use strict'; var <%= _.classify(name) %>Model = Backbone.Model.extend({ + url: '', + + initialize: function() { + }, + defaults: { + }, + + validate: function(attrs, options) { + }, + + parse: function(response, options) { + return response; } }); diff --git a/templates/requirejs/view.js b/templates/requirejs/view.js index 16bd499..d1790a9 100644 --- a/templates/requirejs/view.js +++ b/templates/requirejs/view.js @@ -9,7 +9,23 @@ define([ 'use strict'; var <%= _.classify(name) %>View = Backbone.View.extend({ - template: JST['<%= jst_path %>'] + template: JST['<%= jst_path %>'], + + tagName: 'div', + + id: '', + + className: '', + + events: {}, + + initialize: function () { + this.listenTo(this.model, 'change', this.render); + }, + + render: function () { + this.$el.html(this.template(this.model.toJSON())); + } }); return <%= _.classify(name) %>View; diff --git a/templates/view.js b/templates/view.js index 46c0604..0881fc6 100644 --- a/templates/view.js +++ b/templates/view.js @@ -7,7 +7,23 @@ <%= _.camelize(appname) %>.Views.<%= _.classify(name) %>View = Backbone.View.extend({ - template: JST['<%= jst_path %>'] + template: JST['<%= jst_path %>'], + + tagName: 'div', + + id: '', + + className: '', + + events: {}, + + initialize: function () { + this.listenTo(this.model, 'change', this.render); + }, + + render: function () { + this.$el.html(this.template(this.model.toJSON())); + } });