Skip to content

Commit

Permalink
updating scaffolding to use shorthand @ to replace this
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Fitzgerald committed Sep 4, 2011
1 parent 8f2f3fa commit afa0665
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ class <%= view_namespace %>.<%= singular_name.camelize %>View extends Backbone.V
return false

render: ->
$(this.el).html(this.template(this.options.model.toJSON() ))
$(this.el).html(@template(@options.model.toJSON() ))
return this
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class <%= view_namespace %>.NewView extends Backbone.View
)

render: ->
$(this.el).html(this.template(@options.model.toJSON() ))
$(this.el).html(@template(@options.model.toJSON() ))

this.$("form").backboneLink(@options.model)

Expand Down
12 changes: 6 additions & 6 deletions test/generators/scaffold_generator_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ class ScaffoldGeneratorTest < Rails::Generators::TestCase

assert_file "#{backbone_path}/views/posts/show_view.js.coffee" do |view|
assert_match /class Dummy.Views.Posts.ShowView extends Backbone.View/, view
assert_match /#{Regexp.escape('this.template(this.options.model.toJSON() )')}/, view
assert_match /#{Regexp.escape('@template(@options.model.toJSON() )')}/, view
assert_match /#{Regexp.escape('template: JST["backbone/templates/posts/show"]')}/, view
end

assert_file "#{backbone_path}/views/posts/new_view.js.coffee" do |view|
assert_match /class Dummy.Views.Posts.NewView extends Backbone.View/, view
assert_match /#{Regexp.escape('this.template(@options.model.toJSON() )')}/, view
assert_match /#{Regexp.escape('@template(@options.model.toJSON() )')}/, view
assert_match /#{Regexp.escape('JST["backbone/templates/posts/new"]')}/, view
assert_match /#{Regexp.escape('"submit #new-post": "save"')}/, view
end
Expand All @@ -65,7 +65,7 @@ class ScaffoldGeneratorTest < Rails::Generators::TestCase

assert_file "#{backbone_path}/views/posts/post_view.js.coffee" do |view|
assert_match /class Dummy.Views.Posts.PostView extends Backbone.View/, view
assert_match /#{Regexp.escape('this.template(this.options.model.toJSON() )')}/, view
assert_match /#{Regexp.escape('@template(@options.model.toJSON() )')}/, view
assert_match /#{Regexp.escape('JST["backbone/templates/posts/post"]')}/, view
end
end
Expand All @@ -81,13 +81,13 @@ class ScaffoldGeneratorTest < Rails::Generators::TestCase

assert_file "#{backbone_path}/views/blog_posts/show_view.js.coffee" do |view|
assert_match /class Dummy.Views.BlogPosts.ShowView extends Backbone.View/, view
assert_match /#{Regexp.escape('this.template(this.options.model.toJSON() )')}/, view
assert_match /#{Regexp.escape('@template(@options.model.toJSON() )')}/, view
assert_match /#{Regexp.escape('template: JST["backbone/templates/blog_posts/show"]')}/, view
end

assert_file "#{backbone_path}/views/blog_posts/new_view.js.coffee" do |view|
assert_match /class Dummy.Views.BlogPosts.NewView extends Backbone.View/, view
assert_match /#{Regexp.escape('this.template(@options.model.toJSON() )')}/, view
assert_match /#{Regexp.escape('@template(@options.model.toJSON() )')}/, view
assert_match /#{Regexp.escape('JST["backbone/templates/blog_posts/new"]')}/, view
assert_match /#{Regexp.escape('"submit #new-blog_post": "save"')}/, view
end
Expand All @@ -100,7 +100,7 @@ class ScaffoldGeneratorTest < Rails::Generators::TestCase

assert_file "#{backbone_path}/views/blog_posts/blog_post_view.js.coffee" do |view|
assert_match /class Dummy.Views.BlogPosts.BlogPostView extends Backbone.View/, view
assert_match /#{Regexp.escape('this.template(this.options.model.toJSON() )')}/, view
assert_match /#{Regexp.escape('@template(@options.model.toJSON() )')}/, view
assert_match /#{Regexp.escape('JST["backbone/templates/blog_posts/blog_post"]')}/, view
end
end
Expand Down

0 comments on commit afa0665

Please sign in to comment.