Module: SemanticNavigation::HelperMethods

Defined in:
lib/semantic_navigation/helper_methods.rb

Instance Method Summary collapse

Instance Method Details

#active_item_for(name, level = nil, &block) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/semantic_navigation/helper_methods.rb', line 9

def active_item_for(name, level = nil, &block)
  SemanticNavigation::Configuration.view_object = self
  navigation = SemanticNavigation::Configuration.navigation(name)
  navigation.mark_active
  item = navigation
  while !item.is_a?(SemanticNavigation::Core::Leaf) &&
        !item.sub_elements.find{|e| e.active}.nil? &&
        (!level.nil? ? item.level < level : true)
    item = item.sub_elements.find{|e| e.active}
  end
  if !block_given?
    item != navigation ? item.name(:active_item_for) : ''
  else
    capture(item, &block)  
  end
end


3
4
5
6
7
# File 'lib/semantic_navigation/helper_methods.rb', line 3

def navigation_for(name, options = {})
  render_name = options.delete :as
  render_name ||= :list
  SemanticNavigation::Configuration.new.render(name, render_name, options, self)
end