Sha256: 006241d5863cb7808bff5dd57219d4f12ac179921aea43538d63cb7791abb9ed

Contents?: true

Size: 1.38 KB

Versions: 3

Compression:

Stored size: 1.38 KB

Contents

require "rails/generators"
require File.expand_path("../generator_helper", __FILE__)
include GeneratorHelper

module ReactOnRails
  module Generators
    class ReactNoReduxGenerator < Rails::Generators::Base
      hide!
      source_root(File.expand_path("../templates", __FILE__))

      # --server-rendering
      class_option :server_rendering,
                   type: :boolean,
                   default: false,
                   desc: "Configure for server-side rendering of webpack JavaScript",
                   aliases: "-S"

      def copy_base_files
        base_path = "no_redux/base/"
        %w(client/app/bundles/HelloWorld/components/HelloWorldWidget.jsx
           client/app/bundles/HelloWorld/containers/HelloWorld.jsx).each do |file|
             copy_file(base_path + file, file)
           end
      end

      def copy_server_rendering_files_if_appropriate
        return unless options.server_rendering?
        base_path = "no_redux/server_rendering/"
        file = "client/app/bundles/HelloWorld/startup/HelloWorldAppServer.jsx"
        copy_file(base_path + file, file)
      end

      def template_appropriate_version_of_hello_world_app_client
        filename = "HelloWorldAppClient.jsx"
        location = "client/app/bundles/HelloWorld/startup"
        template("no_redux/base/#{location}/HelloWorldAppClient.jsx.tt", "#{location}/#{filename}")
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
react_on_rails-2.0.0.rc.1 lib/generators/react_on_rails/react_no_redux_generator.rb
react_on_rails-2.0.0.beta.3 lib/generators/react_on_rails/react_no_redux_generator.rb
react_on_rails-2.0.0.beta.2 lib/generators/react_on_rails/react_no_redux_generator.rb