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-15.0.0.alpha.1 lib/generators/react_on_rails/react_no_redux_generator.rb
react_on_rails-14.0.5 lib/generators/react_on_rails/react_no_redux_generator.rb
react_on_rails-14.0.4 lib/generators/react_on_rails/react_no_redux_generator.rb
react_on_rails-14.0.3 lib/generators/react_on_rails/react_no_redux_generator.rb
react_on_rails-14.0.2 lib/generators/react_on_rails/react_no_redux_generator.rb
react_on_rails-14.0.0 lib/generators/react_on_rails/react_no_redux_generator.rb
react_on_rails-13.4.0 lib/generators/react_on_rails/react_no_redux_generator.rb
react_on_rails-13.3.5 lib/generators/react_on_rails/react_no_redux_generator.rb
react_on_rails-13.3.4 lib/generators/react_on_rails/react_no_redux_generator.rb
react_on_rails-13.3.3 lib/generators/react_on_rails/react_no_redux_generator.rb
react_on_rails-13.3.2 lib/generators/react_on_rails/react_no_redux_generator.rb
react_on_rails-13.3.1 lib/generators/react_on_rails/react_no_redux_generator.rb
react_on_rails-13.3.0 lib/generators/react_on_rails/react_no_redux_generator.rb
react_on_rails-13.2.0 lib/generators/react_on_rails/react_no_redux_generator.rb
react_on_rails-13.1.0 lib/generators/react_on_rails/react_no_redux_generator.rb
react_on_rails-13.0.2 lib/generators/react_on_rails/react_no_redux_generator.rb
react_on_rails-13.0.1 lib/generators/react_on_rails/react_no_redux_generator.rb
react_on_rails-13.0.0 lib/generators/react_on_rails/react_no_redux_generator.rb
react_on_rails-13.0.0.beta.0 lib/generators/react_on_rails/react_no_redux_generator.rb
react_on_rails-12.6.0 lib/generators/react_on_rails/react_no_redux_generator.rb