Class: Preview::Generators::ComponentGenerator

Inherits:
Rails::Generators::NamedBase
  • Object
show all
Defined in:
lib/rails/generators/preview/component_generator.rb

Instance Method Summary collapse

Instance Method Details

#create_preview_fileObject



11
12
13
14
15
16
17
# File 'lib/rails/generators/preview/component_generator.rb', line 11

def create_preview_file
  preview_paths = Rails.application.config.view_component.preview_paths
  return if preview_paths.count > 1

  path_prefix = preview_paths.one? ? preview_paths.first : "test/components/previews"
  template "component_preview.rb", File.join(path_prefix, class_path, "#{file_name}_component_preview.rb")
end