From 371fa4a05ee88583e6f8255926cfd3f9fbbbdcc4 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Fri, 15 Apr 2011 16:14:18 -0400 Subject: [PATCH] forgot that views need to return self from render --- spec/bin/backbone-generator_spec.rb | 2 ++ templates/collection_view.js.erb | 1 + templates/view.js.erb | 1 + 3 files changed, 4 insertions(+) diff --git a/spec/bin/backbone-generator_spec.rb b/spec/bin/backbone-generator_spec.rb index a91f9fb..7ee81c6 100644 --- a/spec/bin/backbone-generator_spec.rb +++ b/spec/bin/backbone-generator_spec.rb @@ -32,6 +32,7 @@ describe 'backbone-generator' do File.file?(template = 'app/views/section/model.jst').should be_true File.read(view).should match(/SectionModel/) + File.read(view).should match(/return this/) File.read(view).should match(%r{template: JST\['section/model'\]}) File.read(spec).should match(/SectionModel/) end @@ -47,6 +48,7 @@ describe 'backbone-generator' do File.read(view).should match(/SectionModelsView/) File.read(view).should match(/SectionModelView/) + File.read(view).should match(/return this/) File.read(view).should match(%r{template: JST\['section/models'\]}) File.read(spec).should match(/SectionModelsView/) end diff --git a/templates/collection_view.js.erb b/templates/collection_view.js.erb index 742ce8f..5d63862 100644 --- a/templates/collection_view.js.erb +++ b/templates/collection_view.js.erb @@ -11,6 +11,7 @@ var <%= object_name %>sView = Backbone.View.extend({ }, render: function() { $(this.el).html(this.template()); + return this; }, addOne: function(model) { var view = new <%= object_name %>View({model: model}); diff --git a/templates/view.js.erb b/templates/view.js.erb index defd16c..4994d91 100644 --- a/templates/view.js.erb +++ b/templates/view.js.erb @@ -5,6 +5,7 @@ var <%= object_name %>View = Backbone.View.extend({ }, render: function() { $(this.el).html(this.template()); + return this; } });