Class: Vident::ViewComponent::Generators::ComponentGenerator

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Defined in:
lib/generators/vident/view_component/component/component_generator.rb

Instance Method Summary collapse

Instance Method Details

#create_component_fileObject



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_fileObject



32
33
34
35
36
# File 'lib/generators/vident/view_component/component/component_generator.rb', line 32

def create_controller_file
  return if options[:skip_stimulus] || options[:skip_controller]
  ext = options[:typescript] ? "ts" : "js"
  template "controller.#{ext}.tt", File.join("app/components", class_path, "#{file_name}_component_controller.#{ext}")
end

#create_template_fileObject



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_fileObject



38
39
40
41
# File 'lib/generators/vident/view_component/component/component_generator.rb', line 38

def create_test_file
  return if options[:skip_test]
  template "component_test.rb.tt", File.join("test/components", class_path, "#{file_name}_component_test.rb")
end