Sha256: c5cf47d2cf7f364f2b732925957b7ab8eaceefce2122e9b2bafae57965ac9a99

Contents?: true

Size: 792 Bytes

Versions: 18

Compression:

Stored size: 792 Bytes

Contents

# frozen_string_literal: true

require "rails/generators/erb/component_generator"

module Slim
  module Generators
    class ComponentGenerator < Erb::Generators::ComponentGenerator
      source_root File.expand_path("templates", __dir__)
      class_option :sidecar, type: :boolean, default: false

      def copy_view_file
        template "component.html.slim", destination
      end

      private

      def destination
        if options["sidecar"]
          File.join("app/components", class_path, "#{file_name}_component", "#{file_name}_component.html.slim")
        else
          File.join("app/components", class_path, "#{file_name}_component.html.slim")
        end
      end

      def file_name
        @_file_name ||= super.sub(/_component\z/i, "")
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
view_component-2.25.1 lib/rails/generators/slim/component_generator.rb
view_component-2.25.0 lib/rails/generators/slim/component_generator.rb
view_component-2.24.0 lib/rails/generators/slim/component_generator.rb
view_component-2.23.2 lib/rails/generators/slim/component_generator.rb
view_component-2.23.1 lib/rails/generators/slim/component_generator.rb
view_component-2.23.0 lib/rails/generators/slim/component_generator.rb
view_component-2.22.1 lib/rails/generators/slim/component_generator.rb
view_component-2.22.0 lib/rails/generators/slim/component_generator.rb
view_component-2.21.0 lib/rails/generators/slim/component_generator.rb
view_component-2.20.0 lib/rails/generators/slim/component_generator.rb
view_component-2.19.1 lib/rails/generators/slim/component_generator.rb
view_component-2.19.0 lib/rails/generators/slim/component_generator.rb
view_component-2.18.2 lib/rails/generators/slim/component_generator.rb
view_component-2.18.1 lib/rails/generators/slim/component_generator.rb
view_component-2.18.0 lib/rails/generators/slim/component_generator.rb
view_component-2.17.1 lib/rails/generators/slim/component_generator.rb
view_component-2.17.0 lib/rails/generators/slim/component_generator.rb
view_component-2.16.0 lib/rails/generators/slim/component_generator.rb