Class: ReactOnRails::Generators::ReactNoReduxGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
GeneratorHelper
Defined in:
lib/generators/react_on_rails/react_no_redux_generator.rb

Instance Method Summary collapse

Methods included from GeneratorHelper

#add_documentation_reference, #copy_file_and_missing_parent_directories, #dest_dir_exists?, #dest_file_exists?, #empty_directory_with_keep_file, #keep_file, #setup_file_error, #symlink_dest_file_to_dest_file

Instance Method Details

#copy_base_filesObject



13
14
15
16
17
# File 'lib/generators/react_on_rails/react_no_redux_generator.rb', line 13

def copy_base_files
  base_js_path = "base/base"
  base_files = %w[app/javascript/bundles/HelloWorld/components/HelloWorld.jsx]
  base_files.each { |file| copy_file("#{base_js_path}/#{file}", file) }
end

#create_appropriate_templatesObject



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/generators/react_on_rails/react_no_redux_generator.rb', line 19

def create_appropriate_templates
  base_path = "base/base"
  config = {
    component_name: "HelloWorld",
    app_relative_path: "../bundles/HelloWorld/components/HelloWorld"
  }

  template("#{base_path}/app/javascript/packs/registration.js.tt",
           "app/javascript/packs/hello-world-bundle.js", config)
  template("#{base_path}/app/views/hello_world/index.html.erb.tt",
           "app/views/hello_world/index.html.erb", config)
end