Sha256: fef8e1d55f4039d8a5b0cb90ff2490a03f04059b1a6fa46a8ba286a5fa5a4c23

Contents?: true

Size: 1.07 KB

Versions: 67

Compression:

Stored size: 1.07 KB

Contents

# frozen_string_literal: true

require "rails/generators"
require_relative "generator_helper"

module ReactOnRails
  module Generators
    class ReactNoReduxGenerator < Rails::Generators::Base
      include GeneratorHelper
      Rails::Generators.hide_namespace(namespace)
      source_root(File.expand_path("templates", __dir__))

      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

      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
    end
  end
end

Version data entries

67 entries across 67 versions & 1 rubygems

Version Path
react_on_rails-12.5.2 lib/generators/react_on_rails/react_no_redux_generator.rb
react_on_rails-12.5.1 lib/generators/react_on_rails/react_no_redux_generator.rb
react_on_rails-12.5.0 lib/generators/react_on_rails/react_no_redux_generator.rb
react_on_rails-12.4.0 lib/generators/react_on_rails/react_no_redux_generator.rb
react_on_rails-12.4.0.rc.0 lib/generators/react_on_rails/react_no_redux_generator.rb
react_on_rails-12.3.0 lib/generators/react_on_rails/react_no_redux_generator.rb
react_on_rails-12.2.0 lib/generators/react_on_rails/react_no_redux_generator.rb
react_on_rails-12.1.0 lib/generators/react_on_rails/react_no_redux_generator.rb
react_on_rails-12.0.5.beta.0 lib/generators/react_on_rails/react_no_redux_generator.rb
react_on_rails-12.0.4 lib/generators/react_on_rails/react_no_redux_generator.rb
react_on_rails-11.3.1 lib/generators/react_on_rails/react_no_redux_generator.rb
react_on_rails-11.3.1.beta.0 lib/generators/react_on_rails/react_no_redux_generator.rb
react_on_rails-12.0.3 lib/generators/react_on_rails/react_no_redux_generator.rb
react_on_rails-12.0.3.beta.0 lib/generators/react_on_rails/react_no_redux_generator.rb
react_on_rails-12.0.2 lib/generators/react_on_rails/react_no_redux_generator.rb
react_on_rails-12.0.1 lib/generators/react_on_rails/react_no_redux_generator.rb
react_on_rails-12.0.0 lib/generators/react_on_rails/react_no_redux_generator.rb
react_on_rails-12.0.0.pre.beta.4 lib/generators/react_on_rails/react_no_redux_generator.rb
react_on_rails-12.0.0.pre.beta.3 lib/generators/react_on_rails/react_no_redux_generator.rb
react_on_rails-12.0.0.pre.beta.2 lib/generators/react_on_rails/react_no_redux_generator.rb