diff --git a/bin/backbone-generator b/bin/backbone-generator index e7dd806..dc56927 100755 --- a/bin/backbone-generator +++ b/bin/backbone-generator @@ -27,7 +27,7 @@ class BackboneGenerator < Thor def generate_view template('view.js.erb', "public/javascripts/views/#{underscore_name}_view.js") - template('view.jst.erb', "app/views/#{underscore_name}.jst") + template('view.jst.erb', "app/views/#{underscore_name}s/view.jst") template('view_spec.js.erb', "spec/javascripts/views/#{underscore_name}_view_spec.js") end @@ -38,7 +38,7 @@ class BackboneGenerator < Thor def generate_collection_view template('collection_view.js.erb', "public/javascripts/views/#{underscore_name}s_view.js") - template('collection_view.jst.erb', "app/views/#{underscore_name}s.jst") + template('collection_view.jst.erb', "app/views/#{underscore_name}s/list.jst") template('collection_view_spec.js.erb', "spec/javascripts/views/#{underscore_name}s_view_spec.js") end end diff --git a/spec/bin/backbone-generator_spec.rb b/spec/bin/backbone-generator_spec.rb index 10480c7..0914244 100644 --- a/spec/bin/backbone-generator_spec.rb +++ b/spec/bin/backbone-generator_spec.rb @@ -22,11 +22,11 @@ describe 'backbone-generator' do def should_generate_view File.file?(view = 'public/javascripts/views/section/model_view.js').should be_true File.file?(spec = 'spec/javascripts/views/section/model_view_spec.js').should be_true - File.file?(template = 'app/views/section/model.jst').should be_true + File.file?(template = 'app/views/section/models/view.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(view).should match(%r{template: JST\['section/models/view'\]}) File.read(spec).should match(/SectionModel/) end @@ -42,12 +42,12 @@ describe 'backbone-generator' do def should_generate_collection_view File.file?(view = 'public/javascripts/views/section/models_view.js').should be_true File.file?(spec = 'spec/javascripts/views/section/models_view_spec.js').should be_true - File.file?(template = 'app/views/section/models.jst').should be_true + File.file?(template = 'app/views/section/models/list.jst').should be_true 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(view).should match(%r{template: JST\['section/models/list'\]}) File.read(spec).should match(/SectionModelsView/) end diff --git a/templates/collection_view.js.erb b/templates/collection_view.js.erb index 5d63862..aadedb9 100644 --- a/templates/collection_view.js.erb +++ b/templates/collection_view.js.erb @@ -1,5 +1,5 @@ var <%= object_name %>sView = Backbone.View.extend({ - template: JST['<%= underscore_name %>s'], + template: JST['<%= underscore_name %>s/list'], initialize: function(collection) { _.bindAll(this, 'render', 'addOne', 'addAll'); diff --git a/templates/view.js.erb b/templates/view.js.erb index 4994d91..76d1990 100644 --- a/templates/view.js.erb +++ b/templates/view.js.erb @@ -1,5 +1,5 @@ var <%= object_name %>View = Backbone.View.extend({ - template: JST['<%= underscore_name %>'], + template: JST['<%= underscore_name %>s/view'], initialize: function() { _.bindAll(this, 'render'); },