Module: Avo::Concerns::HasHTMLAttributes

Extended by:
ActiveSupport::Concern
Included in:
Fields::BaseField
Defined in:
lib/avo/concerns/has_html_attributes.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#htmlObject (readonly)

Returns the value of attribute html.



6
7
8
# File 'lib/avo/concerns/has_html_attributes.rb', line 6

def html
  @html
end

Instance Method Details

#get_html(name = nil, element:, view:) ⇒ Object

Used to get attributes for elements and views

examples: get_html :data, view: :edit, element: :input get_html :classes, view: :show, element: :wrapper get_html :styles, view: :index, element: :wrapper



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/avo/concerns/has_html_attributes.rb', line 14

def get_html(name = nil, element:, view:)
  if [view, element].any?(&:nil?) || Avo::App.license.lacks_with_trial(:stimulus_js_integration)
    default_attribute_value name
  end

  parsed = parse_html

  attributes = if parsed.is_a? Hash
    get_html_from_hash name, element: element, hash: parsed, view: view
  elsif parsed.is_a? Avo::HTML::Builder
    get_html_from_block name, element: element, html_builder: parsed, view: view
  elsif parsed.nil?
    # Handle empty parsed by returning an empty state
    default_attribute_value name
  end

  add_default_data_attributes attributes, name, element, view
end