Module: Facades::Helpers::Navigation
- Defined in:
- lib/facades/helpers/navigation.rb
Overview
Convenience helpers for building navigation lists, and defining ‘on’ states.
Instance Method Summary collapse
-
#nav(container = :ol, html_attrs = {}, heading = nil, &block) ⇒ Object
Creates a navigational list format, including a parent list / wrapper.
-
#nav_link(text, path, attrs = {}, wrapper = :li, &block) ⇒ Object
(also: #nav_link_to)
Creates a link wrapped in a list item, to be used within a list-based navigation.
Instance Method Details
#nav(container = :ol, html_attrs = {}, heading = nil, &block) ⇒ Object
Creates a navigational list format, including a parent list / wrapper. Useful for nested list navigation
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/facades/helpers/navigation.rb', line 77 def nav(container = :ol, html_attrs = {}, heading = nil, &block) wrapper_attrs = html_attrs.delete(:wrapper) || {} built = if Facades.enable_html5 inner = content_tag(container, capture(&block), wrapper_attrs) inner = (content_tag(:h3, heading) << inner) unless heading.nil? content_tag(:nav, html_attrs) do inner end else content_tag(container, capture(&block), html_attrs) end built = built.html_safe if built.respond_to?(:html_safe) built end |
#nav_link(text, path, attrs = {}, wrapper = :li, &block) ⇒ 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 35 36 37 38 39 |
# File 'lib/facades/helpers/navigation.rb', line 27 def nav_link(text, path, attrs = {}, wrapper = :li, &block) if block_given? return sub_nav_link(text, path, attrs, wrapper, :ol, &block) end link_attrs = update_link_attrs(path, attrs) wrapper_attrs = link_attrs.delete(:wrapper) child_link = link_to(text, path, link_attrs) built = (wrapper === false ? child_link : content_tag(wrapper, child_link, wrapper_attrs)) built = built.html_safe if built.respond_to?(:html_safe) built end |