Module: Shoelace::Components::SlSelectRenderable

Included in:
SlCollectionSelect, SlGroupedCollectionSelect, SlSelect
Defined in:
app/helpers/shoelace/components/sl_select.rb

Constant Summary collapse

EMPTY =
"".html_safe.freeze

Instance Method Summary collapse

Instance Method Details

#select_content_tag(option_tags, _options, html_options) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/helpers/shoelace/components/sl_select.rb', line 10

def (option_tags, _options, html_options)
  html_options = html_options.stringify_keys
  html_options['value'] ||= value
  html_options["invalid"] = html_options["data-invalid"] = "" if object_has_errors?
  add_default_name_and_id(html_options)

  @template_object.("sl-select", html_options) do
    "".html_safe.tap do |html|
      html.safe_concat(option_tags)
      html.safe_concat(@template_object.capture(&slot) || EMPTY) if slot
    end
  end
end