Class: HotwiredComponent::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- HotwiredComponent::InstallGenerator
- Defined in:
- lib/generators/hotwired_component/install/install_generator.rb
Instance Method Summary collapse
-
#add_application_component ⇒ Object
def install_hotwired_rails rake “hotwire:install” end.
- #add_component_controllers ⇒ Object
- #update_webpacker_config ⇒ Object
Instance Method Details
#add_application_component ⇒ Object
def install_hotwired_rails
rake "hotwire:install"
end
9 10 11 12 |
# File 'lib/generators/hotwired_component/install/install_generator.rb', line 9 def add_application_component template "application_component.rb.erb", "app/components/application_component.rb" end |
#add_component_controllers ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/generators/hotwired_component/install/install_generator.rb', line 14 def add_component_controllers append_to_file "app/javascript/controllers/index.js" do " context = require.context(\"../../components\", true, /_controller\\.js$/)\n application.load(definitionsFromContext(context)) \n JAVASCRIPT\n end\nend\n" |
#update_webpacker_config ⇒ Object
23 24 25 26 |
# File 'lib/generators/hotwired_component/install/install_generator.rb', line 23 def update_webpacker_config gsub_file "config/webpacker.yml", "additional_paths: [", "additional_paths: [\"app/components\"" end |