Sha256: 595771ee61c47712d1c4b77bac884858967ef5a57706b9ad0e11efa9c9a9aeb5

Contents?: true

Size: 809 Bytes

Versions: 1

Compression:

Stored size: 809 Bytes

Contents

# frozen_string_literal: true

module Primer
  # :nodoc:
  class FormComponents
    def self.from_input(input_klass)
      Class.new(Primer::Component) do
        @input_klass = input_klass

        class << self
          attr_reader :input_klass
        end

        def initialize(**system_arguments, &block)
          @system_arguments = system_arguments
          @block = block
        end

        def call
          builder = ActionView::Helpers::FormBuilder.new(
            nil, nil, __vc_original_view_context, {}
          )

          input = self.class.input_klass.new(
            builder: builder,
            form: nil,
            **@system_arguments,
            &@block
          )

          input.render_in(__vc_original_view_context) { content }
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
primer_view_components-0.0.86 lib/primer/form_components.rb