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
-
#html ⇒ Object
readonly
Returns the value of attribute html.
Instance Method Summary collapse
-
#get_html(name = nil, element:, view:) ⇒ Object
Used to get attributes for elements and views.
Instance Attribute Details
#html ⇒ Object (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 |
# 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 attributes = if html_builder.is_a? Hash get_html_from_hash name, element: element, view: view elsif html_builder.is_a? Avo::HTML::Builder get_html_from_block name, element: element, view: view elsif html_builder.nil? # Handle empty html_builder by returning an empty state default_attribute_value name end add_default_data_attributes attributes, name, element, view end |