Module: Motr::Helpers::Navigation
- Defined in:
- lib/motr/helpers/navigation.rb
Overview
Convenience helpers for building navigation lists, and defining ‘on’ states.
Instance Method Summary collapse
-
#nav_link_to(text, path, attrs = {}, wrapper = :li) ⇒ Object
(also: #nav_link)
Creates a link wrapped in a list item, to be used within a list-based navigation.
-
#navigation(text, path, attrs = {}, wrapper = :li, container = :ol, &block) ⇒ Object
Creates a navigational list format, including a parent list / wrapper.
Instance Method Details
#nav_link_to(text, path, attrs = {}, wrapper = :li) ⇒ Object Also known as:
Creates a link wrapped in a list item, to be used within a list-based navigation.
27 28 29 30 31 32 33 34 |
# File 'lib/motr/helpers/navigation.rb', line 27 def nav_link_to(text, path, attrs = {}, wrapper = :li) link_attrs = update_link_attrs(path, attrs) wrapper_attrs = link_attrs.delete(:wrapper) child_link = link_to(text, path, link_attrs) wrapper === false ? child_link : content_tag(wrapper, child_link, wrapper_attrs) end |
#navigation(text, path, attrs = {}, wrapper = :li, container = :ol, &block) ⇒ Object
Creates a navigational list format, including a parent list / wrapper. Useful for nested list navigation
62 63 64 65 66 67 68 69 70 71 |
# File 'lib/motr/helpers/navigation.rb', line 62 def (text, path, attrs = {}, wrapper = :li, container = :ol, &block) wrapper_attrs = attrs.delete(:wrapper) link_attrs = update_link_attrs(path, attrs.merge(:wrapper => (attrs.delete(:item) || {}) )) parent_link = nav_link_to(text, path, attrs, false) child_links = content_tag(container, capture(&block), wrapper_attrs) content_tag(wrapper, (parent_link << child_links), wrapper_attrs) end |