more granularity in the view generation, match rails better
This commit is contained in:
parent
d2dcd4569c
commit
d3cbfd9be2
|
@ -27,7 +27,7 @@ class BackboneGenerator < Thor
|
||||||
|
|
||||||
def generate_view
|
def generate_view
|
||||||
template('view.js.erb', "public/javascripts/views/#{underscore_name}_view.js")
|
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")
|
template('view_spec.js.erb', "spec/javascripts/views/#{underscore_name}_view_spec.js")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ class BackboneGenerator < Thor
|
||||||
|
|
||||||
def generate_collection_view
|
def generate_collection_view
|
||||||
template('collection_view.js.erb', "public/javascripts/views/#{underscore_name}s_view.js")
|
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")
|
template('collection_view_spec.js.erb', "spec/javascripts/views/#{underscore_name}s_view_spec.js")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -22,11 +22,11 @@ describe 'backbone-generator' do
|
||||||
def should_generate_view
|
def should_generate_view
|
||||||
File.file?(view = 'public/javascripts/views/section/model_view.js').should be_true
|
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?(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(/SectionModel/)
|
||||||
File.read(view).should match(/return this/)
|
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/)
|
File.read(spec).should match(/SectionModel/)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -42,12 +42,12 @@ describe 'backbone-generator' do
|
||||||
def should_generate_collection_view
|
def should_generate_collection_view
|
||||||
File.file?(view = 'public/javascripts/views/section/models_view.js').should be_true
|
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?(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(/SectionModelsView/)
|
||||||
File.read(view).should match(/SectionModelView/)
|
File.read(view).should match(/SectionModelView/)
|
||||||
File.read(view).should match(/return this/)
|
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/)
|
File.read(spec).should match(/SectionModelsView/)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
var <%= object_name %>sView = Backbone.View.extend({
|
var <%= object_name %>sView = Backbone.View.extend({
|
||||||
template: JST['<%= underscore_name %>s'],
|
template: JST['<%= underscore_name %>s/list'],
|
||||||
initialize: function(collection) {
|
initialize: function(collection) {
|
||||||
_.bindAll(this, 'render', 'addOne', 'addAll');
|
_.bindAll(this, 'render', 'addOne', 'addAll');
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
var <%= object_name %>View = Backbone.View.extend({
|
var <%= object_name %>View = Backbone.View.extend({
|
||||||
template: JST['<%= underscore_name %>'],
|
template: JST['<%= underscore_name %>s/view'],
|
||||||
initialize: function() {
|
initialize: function() {
|
||||||
_.bindAll(this, 'render');
|
_.bindAll(this, 'render');
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue