Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

install into application.js.coffee #111

Closed
wants to merge 1 commit into from

4 participants

@joelturnbull

install generator will check for and insert into application.js.coffee before inserting into application.js.

In either case, will insert before require statements with or without spaces ('//= require' and '//=require')

@joelturnbull joelturnbull install generator will check for and insert into application.js.coffe…
…e before checking for application.js.

In either case, will support require statements with or without spaces ('//= require' and '//=require')
4cfae5b
@sunny

Would love that, as today rails g backbone:install breaks with No such file or directory - assets/javascripts/application.js (Errno::ENOENT).

@manusajith
Collaborator

Fixed in master.
@joelturnbull Thanks.!

@manusajith manusajith closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 18, 2012
  1. @joelturnbull

    install generator will check for and insert into application.js.coffe…

    joelturnbull authored
    …e before checking for application.js.
    
    In either case, will support require statements with or without spaces ('//= require' and '//=require')
This page is out of date. Refresh to see the latest.
Showing with 8 additions and 2 deletions.
  1. +8 −2 lib/generators/backbone/install/install_generator.rb
View
10 lib/generators/backbone/install/install_generator.rb
@@ -13,8 +13,14 @@ class InstallGenerator < Rails::Generators::Base
:desc => "Skip Git ignores and keeps"
def inject_backbone
- inject_into_file "app/assets/javascripts/application.js", :before => "//= require_tree" do
+ if File.exists?("app/assets/javascripts/application.js.coffee")
+ inject_into_file "app/assets/javascripts/application.js.coffee", :before => /#=\s*require_tree/ do
+ "#= require underscore\n#= require backbone\n#= require backbone_rails_sync\n#= require backbone_datalink\n#= require backbone/#{application_name.underscore}\n"
+ end
+ else
+ inject_into_file "app/assets/javascripts/application.js", :before => /\/\/=\s*require_tree/ do
"//= require underscore\n//= require backbone\n//= require backbone_rails_sync\n//= require backbone_datalink\n//= require backbone/#{application_name.underscore}\n"
+ end
end
end
@@ -31,4 +37,4 @@ def create_app_file
end
end
-end
+end
Something went wrong with that request. Please try again.