Class: Vident::ViewComponent::Generators::ComponentGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- Vident::ViewComponent::Generators::ComponentGenerator
- Defined in:
- lib/generators/vident/view_component/component/component_generator.rb
Instance Method Summary collapse
- #create_component_file ⇒ Object
- #create_controller_file ⇒ Object
- #create_template_file ⇒ Object
- #create_test_file ⇒ Object
Instance Method Details
#create_component_file ⇒ Object
24 25 26 |
# File 'lib/generators/vident/view_component/component/component_generator.rb', line 24 def create_component_file template "component.rb.tt", File.join("app/components", class_path, "#{file_name}_component.rb") end |
#create_controller_file ⇒ Object
32 33 34 35 36 |
# File 'lib/generators/vident/view_component/component/component_generator.rb', line 32 def create_controller_file return if [:skip_stimulus] || [:skip_controller] ext = [:typescript] ? "ts" : "js" template "controller.#{ext}.tt", File.join("app/components", class_path, "#{file_name}_component_controller.#{ext}") end |
#create_template_file ⇒ Object
28 29 30 |
# File 'lib/generators/vident/view_component/component/component_generator.rb', line 28 def create_template_file template "component.html.erb.tt", File.join("app/components", class_path, "#{file_name}_component.html.erb") end |
#create_test_file ⇒ Object
38 39 40 41 |
# File 'lib/generators/vident/view_component/component/component_generator.rb', line 38 def create_test_file return if [:skip_test] template "component_test.rb.tt", File.join("test/components", class_path, "#{file_name}_component_test.rb") end |