module Bootstrap4RailsComponents::Bootstrap::Utilities::Wrappable
Allows component to swap out the main component wrapping element (ex. :div vs. :span) Pass in :as – only unique logic at the moment is converting :link to :a for tag generation
Attributes
as[RW]
Public Instance Methods
utility_initialize()
click to toggle source
Calls superclass method
# File lib/bootstrap4_rails_components/bootstrap/utilities/wrappable.rb, line 12 def utility_initialize self.as = options.fetch(:as, automatic_as) super end
Private Instance Methods
assistive_html_attributes()
click to toggle source
Calls superclass method
# File lib/bootstrap4_rails_components/bootstrap/utilities/wrappable.rb, line 19 def assistive_html_attributes if as == :button super.merge(type: options.fetch(:type, 'button')) # prefer type submit else super end end
automatic_as()
click to toggle source
# File lib/bootstrap4_rails_components/bootstrap/utilities/wrappable.rb, line 27 def automatic_as if href :a elsif options[:type] == 'submit' :button else default_html_wrapper_element end end
default_html_wrapper_element()
click to toggle source
Set default_html_wrapper_element
on individual components as needed
# File lib/bootstrap4_rails_components/bootstrap/utilities/wrappable.rb, line 38 def default_html_wrapper_element @default_html_wrapper_element ||= :span end
non_html_attribute_options()
click to toggle source
Calls superclass method
# File lib/bootstrap4_rails_components/bootstrap/utilities/wrappable.rb, line 42 def non_html_attribute_options super.push(:as) end