Module | SimpleNavigation::Helpers |
In: |
lib/simple_navigation/rendering/helpers.rb
|
View helpers to render the navigation.
Use render_navigation as following to render your navigation:
#primary_navigation= render_navigation(:level => 1) #sub_navigation= render_navigation(:level => 2) #nested_navigation= render_navigation #top_navigation= render_navigation(:level => 1..2) #sidebar_navigation= render_navigation(:level => 3)
Renders the navigation according to the specified options-hash.
The following options are supported:
# File lib/simple_navigation/rendering/helpers.rb, line 34 def render_navigation(options={}) options = apply_defaults(options) ctx = options.delete(:context) SimpleNavigation.init_adapter_from self SimpleNavigation.load_config(ctx) SimpleNavigation::Configuration.eval_config(ctx) SimpleNavigation.config.items(options[:items]) if options[:items] SimpleNavigation.handle_explicit_navigation if SimpleNavigation.respond_to?(:handle_explicit_navigation) raise "no primary navigation defined, either use a navigation config file or pass items directly to render_navigation" unless SimpleNavigation.primary_navigation active_item_container = SimpleNavigation.active_item_container_for(options[:level]) active_item_container.render(options) unless active_item_container.nil? end