Class: StimulusPlumbers::Form::Fields::InputGroup

Inherits:
Plumber::Base
  • Object
show all
Defined in:
lib/stimulus_plumbers/form/fields/input_group.rb

Constant Summary

Constants included from Plumber::HtmlOptions

Plumber::HtmlOptions::STIMULUS_SPACEJOIN_KEYS

Instance Attribute Summary

Attributes inherited from Plumber::Base

#template

Instance Method Summary collapse

Methods inherited from Plumber::Base

#initialize, #theme

Methods included from Plumber::HtmlOptions

#extract_classes, #merge_data_options, #merge_html_options, #merge_string_option, #normalize_part

Constructor Details

This class inherits a constructor from StimulusPlumbers::Plumber::Base

Instance Method Details

#render(leading: nil, trailing: nil, error: false, **wrapper_opts, &block) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/stimulus_plumbers/form/fields/input_group.rb', line 7

def render(leading: nil, trailing: nil, error: false, **wrapper_opts, &block)
  html_options = merge_html_options(
    theme.resolve(:form_input_group, error: error),
    wrapper_opts
  )
  template.(:div, **html_options) do
    template.safe_join(
      [
        leading.respond_to?(:call) ? leading.call : leading,
        template.capture(&block),
        trailing.respond_to?(:call) ? trailing.call : trailing
      ]
    )
  end
end