Class: HotwiredComponent::ComponentGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- HotwiredComponent::ComponentGenerator
- Defined in:
- lib/generators/hotwired_component/component/component_generator.rb
Overview
Generates ViewComponents with Stimulus/Hotwire
Instance Method Summary collapse
- #create_component_file ⇒ Object
- #create_javascript_file ⇒ Object
- #create_scss_file ⇒ Object
- #create_template_file ⇒ Object
- #create_test_file ⇒ Object
Instance Method Details
#create_component_file ⇒ Object
9 10 11 12 13 14 |
# File 'lib/generators/hotwired_component/component/component_generator.rb', line 9 def create_component_file template( "component.rb.erb", File.join("app/components", class_path, "#{file_name}_component.rb") ) end |
#create_javascript_file ⇒ Object
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/generators/hotwired_component/component/component_generator.rb', line 38 def create_javascript_file template( "component_controller.js.erb", File.join( "app/components", class_path, "#{file_name}_component/component_controller.js" ) ) end |
#create_scss_file ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/generators/hotwired_component/component/component_generator.rb', line 16 def create_scss_file template( "component.scss.erb", File.join( "app/components", class_path, "#{file_name}_component/#{file_name}_component.scss" ) ) end |
#create_template_file ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/generators/hotwired_component/component/component_generator.rb', line 27 def create_template_file create_file( File.join( "app/components", class_path, "#{file_name}_component/#{file_name}_component.html.erb" ), component_div ) end |
#create_test_file ⇒ Object
49 50 51 52 53 54 55 |
# File 'lib/generators/hotwired_component/component/component_generator.rb', line 49 def create_test_file template( "component_test.rb.erb", File.join("test/components", class_path, "#{file_name}_component_test.rb") ) end |