View helpers to render the navigation.
Use #render_navigation as following to render your navigation:
call render_navigation without :level option to render your
complete navigation as nested tree.
call render_navigation(level: x) to render a specific
navigation level (e.g. level: 1 to render your primary navigation, level: 2
to render the sub navigation and so forth)
call render_navigation(:level => 2..3) to render navigation
levels 2 and 3).
For example, you could use #render_navigation(level: 1) to render your primary navigation as tabs and #render_navigation(level: 2..3) to render the rest of the navigation as a tree in a sidebar.
#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)
# File lib/simple_navigation/helpers.rb, line 43 def self.apply_defaults(options) options[:level] = options.delete(:levels) if options[:levels] { context: :default, level: :all }.merge(options) end
# File lib/simple_navigation/helpers.rb, line 27 def self.load_config(options, includer, &block) context = options.delete(:context) SimpleNavigation.init_adapter_from includer SimpleNavigation.load_config context SimpleNavigation::Configuration.eval_config context if block_given? || options[:items] SimpleNavigation.config.items(options[:items], &block) end unless SimpleNavigation.primary_navigation fail 'no primary navigation defined, either use a navigation config ' 'file or pass items directly to render_navigation' end end