generators/navigation_config/templates/config/navigation.rb in andi-simple-navigation-1.1.2 vs generators/navigation_config/templates/config/navigation.rb in andi-simple-navigation-1.2.0
- old
+ new
@@ -11,18 +11,24 @@
navigation.items do |primary|
# Add an item to the primary navigation. The following params apply:
# key - a symbol which uniquely defines your navigation item in the scope of the primary_navigation
# name - will be displayed in the rendered navigation. This can also be a call to your I18n-framework.
# url - the address that the generated item links to. You can also use url_helpers (named routes, restful routes helper, url_for etc.)
- # html_options - can be used to specify attributes that will be included in the rendered navigation item (e.g. id, class etc.)
+ # options - can be used to specify attributes that will be included in the rendered navigation item (e.g. id, class etc.)
#
- primary.item :key_1, 'name', url, html_options
+ primary.item :key_1, 'name', url, options
# Add an item which has a sub navigation (same params, but with block)
- primary.item :key_2, 'name', url, html_options do |sub_nav|
+ primary.item :key_2, 'name', url, options do |sub_nav|
# Add an item to the sub navigation (same params again)
- sub_nav.item :key_2_1, 'name', url, html_options
+ sub_nav.item :key_2_1, 'name', url, options
end
+
+ # You can also specify a condition-proc that needs to be fullfilled to display an item.
+ # Conditions are part of the options. They are evaluated in the context of the views,
+ # thus you can use all the methods and vars you have available in the views.
+ primary.item :key_3, 'Admin', url, :class => 'special', :if => Proc.new { current_user.admin? }
+ primary.item :key_4, 'Account', url, :unless => Proc.new { logged_in? }
end
end
\ No newline at end of file