Class: Initjs::Generators::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
ResourceHelpers
Defined in:
lib/generators/initjs/install/install_generator.rb

Instance Method Summary collapse

Methods included from ResourceHelpers

#application_name, #application_path, #js_app_name

Instance Method Details

#create_app_fileObject



16
17
18
19
20
21
22
# File 'lib/generators/initjs/install/install_generator.rb', line 16

def create_app_file
  template "app.coffee", "#{application_path}/#{application_name.underscore}.js.coffee"

  # Alerts
  puts "\n\nInclude the Initjs tag in your application layout (usually found at app/view/layouts/application.html.erb) after the body tag."
  puts "<%= initjs_tag '#{application_name}' %>"
end

#inject_backboneObject



10
11
12
13
14
# File 'lib/generators/initjs/install/install_generator.rb', line 10

def inject_backbone
  inject_into_file "app/assets/javascripts/application.js", before: "//= require_tree" do
    "//= require #{application_name.underscore}/#{application_name.underscore}.js\n//= require init.js\n"
  end
end