Module: RailsBootstrapHelpers::Helpers::OptionsHelper
- Included in:
- BaseHelper, ButtonHelper, LabelHelper, NavigationHelper
- Defined in:
- lib/rails-bootstrap-helpers/helpers/options_helper.rb
Instance Method Summary collapse
-
#append_class!(options, *new_classes) ⇒ Object
Appends the given classes on the given options hash.
-
#bs_options(options, html_options = {}) ⇒ Object
Handles general Bootstrap options available for all Bootstrap helpers.
Instance Method Details
#append_class!(options, *new_classes) ⇒ Object
Appends the given classes on the given options hash.
It will look for both the “class” and :class key. This will create a new :class key in the given hash if neither exist.
40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/rails-bootstrap-helpers/helpers/options_helper.rb', line 40 def append_class! (, *new_classes) return if new_classes.empty? key = .key?("class") ? "class" : :class cls = [key].to_s || "" if cls.present? && new_classes.first.present? cls << " " end cls << new_classes.join(" ") [key] = cls end |
#bs_options(options, html_options = {}) ⇒ Object
Handles general Bootstrap options available for all Bootstrap helpers.
Any option not specify below are kept intact.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/rails-bootstrap-helpers/helpers/options_helper.rb', line 17 def (, = {}) = .reverse_merge() if tooltip = .delete(:tooltip) [:"data-toggle"] ||= "tooltip" [:title] ||= tooltip if tooltip_position = .delete(:tooltip_position) [:"data-placement"] ||= tooltip_position end end end |