Class: Tags::Domternal

Inherits:
Base
  • Object
show all
Includes:
Placeholderable
Defined in:
app/helpers/domternal/tag_helper.rb

Instance Method Summary collapse

Instance Method Details

#render(&block) ⇒ Object



58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'app/helpers/domternal/tag_helper.rb', line 58

def render(&block)
  options = @options.stringify_keys
  add_default_name_and_field(options)
  options["input"] ||= dom_id(object, [options["id"], :domternal_input].compact.join("_")) if object

  attribute_options = object.class.try(:domternal_attributes)&.dig(@method_name.to_sym) || {}
  options["extensions"] ||= attribute_options[:extensions]
  options["toolbar"] = attribute_options[:toolbar] unless options.key?("toolbar")

  html_tag = @template_object.domternal_area_tag(
    options.delete("name"), options.fetch("value") { value }, options.except("value"), &block
  )
  error_wrapping(html_tag)
end