Sha256: 5fb1002a290899c7cb0bd8a5f054551170ce266d1103cb8ef4547f421d475c1c

Contents?: true

Size: 836 Bytes

Versions: 12

Compression:

Stored size: 836 Bytes

Contents

# frozen_string_literal: true

require "rails/generators/erb/component_generator"

module Haml
  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
        if !options["inline"]
          template "component.html.haml", destination
        end
      end

      private

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

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

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
view_component-2.31.2 lib/rails/generators/haml/component_generator.rb
view_component-2.34.0 lib/rails/generators/haml/component_generator.rb
view_component-2.33.0 lib/rails/generators/haml/component_generator.rb
view_component-2.32.0 lib/rails/generators/haml/component_generator.rb
view_component-2.31.1 lib/rails/generators/haml/component_generator.rb
view_component-2.31.0 lib/rails/generators/haml/component_generator.rb
view_component-2.30.0 lib/rails/generators/haml/component_generator.rb
view_component-2.29.0 lib/rails/generators/haml/component_generator.rb
view_component-2.28.0 lib/rails/generators/haml/component_generator.rb
view_component-2.27.0 lib/rails/generators/haml/component_generator.rb
view_component-2.26.1 lib/rails/generators/haml/component_generator.rb
view_component-2.26.0 lib/rails/generators/haml/component_generator.rb