Module: EasyMenu::Helpers
- Included in:
- MenuBar, MenuBar::AbstractContent
- Defined in:
- lib/easy_menu_helpers.rb
Constant Summary collapse
- HTML_OPTIONS =
[:id, :class, :title, :style, :data]
Instance Method Summary collapse
-
#config_name ⇒ Object
Determines the config name from the class name.
- #css_class ⇒ Object
- #html_option_keys ⇒ Object
- #merge_class(hash, *classes) ⇒ Object
- #wrap_content(content) ⇒ Object
- #wrapper_element ⇒ Object
Instance Method Details
#config_name ⇒ Object
Determines the config name from the class name. e.g. MenuBar => ‘menu_bar’
7 8 9 |
# File 'lib/easy_menu_helpers.rb', line 7 def config_name self.class.name.demodulize.underscore end |
#css_class ⇒ Object
11 12 13 |
# File 'lib/easy_menu_helpers.rb', line 11 def css_class config[:"#{config_name}_class"] end |
#html_option_keys ⇒ Object
32 33 34 |
# File 'lib/easy_menu_helpers.rb', line 32 def html_option_keys HTML_OPTIONS + @options.keys.select{|key| key.to_s.starts_with? 'data-'} end |
#merge_class(hash, *classes) ⇒ Object
27 28 29 30 |
# File 'lib/easy_menu_helpers.rb', line 27 def merge_class(hash, *classes) hash[:class] = ([hash[:class]] + classes.flatten).select(&:present?).join(' ') return hash end |
#wrap_content(content) ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/easy_menu_helpers.rb', line 19 def wrap_content(content) if (wrapper_element) @template.content_tag wrapper_element, content, else content end end |
#wrapper_element ⇒ Object
15 16 17 |
# File 'lib/easy_menu_helpers.rb', line 15 def wrapper_element config[:"#{config_name}_element"] end |