Module: SiteMap::ViewHelpers
- Defined in:
- lib/site_map/view_helpers.rb
Instance Method Summary collapse
- #display_crumbs(options = {}) ⇒ Object
- #display_joined_view_nodes(view_nodes, options = {}) ⇒ Object
- #display_menu ⇒ Object
- #display_title(options = {}) ⇒ Object
-
#view_node_label(view_node) ⇒ Object
subbing hash options into view node label, code thanks to kelredd-useful.
-
#view_node_label_options ⇒ Object
Override in view scope to resolve against your labels.
- #view_node_url(view_node) ⇒ Object
- #view_node_visible(view_node) ⇒ Object (also: #view_node_visible?)
Instance Method Details
#display_crumbs(options = {}) ⇒ Object
30 31 32 33 |
# File 'lib/site_map/view_helpers.rb', line 30 def display_crumbs( = {}) [:html] ||= {:class => "breadcrumb"} self.display_joined_view_nodes(@view_node.self_and_ancestors, ) end |
#display_joined_view_nodes(view_nodes, options = {}) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/site_map/view_helpers.rb', line 38 def display_joined_view_nodes(view_nodes, = {}) = { :connector => " > ", :html => true }.merge() display_view_nodes = view_nodes.collect do |view_node| if [:html] = [:html].kind_of?(::Hash) ? [:html] : {} content_tag(:a, view_node_label(view_node), .merge({ :href => view_node_url(view_node) })) else view_node_label(view_node) end end display_connector = if [:html] content_tag(:span, [:connector]) else [:connector] end display_view_nodes.join(display_connector) end |
#display_menu ⇒ Object
34 35 36 |
# File 'lib/site_map/view_helpers.rb', line 34 def end |
#display_title(options = {}) ⇒ Object
25 26 27 28 29 |
# File 'lib/site_map/view_helpers.rb', line 25 def display_title( = {}) self.display_joined_view_nodes([@view_node.parent, @view_node], .merge({ :html => false })) end |
#view_node_label(view_node) ⇒ Object
subbing hash options into view node label, code thanks to kelredd-useful
10 11 12 13 14 15 16 |
# File 'lib/site_map/view_helpers.rb', line 10 def view_node_label(view_node) label_string = view_node.label.dup .each do |label_key, value| label_string.gsub!(":#{label_key}", value.to_s) end label_string end |
#view_node_label_options ⇒ Object
Override in view scope to resolve against your labels
5 6 7 |
# File 'lib/site_map/view_helpers.rb', line 5 def {} end |
#view_node_url(view_node) ⇒ Object
17 18 19 |
# File 'lib/site_map/view_helpers.rb', line 17 def view_node_url(view_node) eval(view_node.url.to_s) end |
#view_node_visible(view_node) ⇒ Object Also known as: view_node_visible?
20 21 22 |
# File 'lib/site_map/view_helpers.rb', line 20 def view_node_visible(view_node) eval(view_node.visible.to_s) end |