class ReactWebpackRails::Install::ExampleGenerator

Public Instance Methods

controller_and_view() click to toggle source
# File lib/generators/react_webpack_rails/install/example_generator.rb, line 23
def controller_and_view
  copy_file 'examples/react_examples_controller.rb', 'app/controllers/react_examples_controller.rb'
  template = "examples/#{options.server_side ? 'ssr-' : ''}component_view.html.erb"
  copy_file template, 'app/views/react_examples/component.html.erb'
end
es6_example() click to toggle source
# File lib/generators/react_webpack_rails/install/example_generator.rb, line 12
      def es6_example
        copy_file 'react/components/hello-world-test.jsx', 'app/react/components/hello-world-test.jsx'
        copy_file 'react/components/hello-world.jsx', 'app/react/components/hello-world.jsx'
        inject_into_file 'app/react/index.js', after: "RWR.run();\n" do <<-'JS'.strip_heredoc

          import HelloWorld from './components/hello-world';
          RWR.registerComponent('HelloWorld', HelloWorld);
          JS
        end
      end
example_route() click to toggle source
# File lib/generators/react_webpack_rails/install/example_generator.rb, line 29
def example_route
  route "get 'react_examples/component', to: 'react_examples#component', as: :component"
end