Skip to content

Instantly share code, notes, and snippets.

@kirel
Last active October 12, 2015 14:08
Show Gist options
  • Select an option

  • Save kirel/4038821 to your computer and use it in GitHub Desktop.

Select an option

Save kirel/4038821 to your computer and use it in GitHub Desktop.
Idea for plain dumb navigation active state
%body
%nav.main
%ul
%li= link_to 'main 1', some_path, class: active_navigation_item?(:main) # => true
%li= link_to 'main 2', some_path, class: active_navigation_item?(:more) # => false
= yield
module NavigationHelper
# set active navigation item state
def active_nagigation_item(*hierarchy)
...
end
# get active navigation item state
def active_navigation_item?(*hierarchy)
...
end
end
- active_navigation_item :main, :second
%nav.second
%ul
%li= link_to 'second 1', another_path, class: active_navigation_item?(:main, :second) # => true
%li= link_to 'second 2', another_path, class: active_navigation_item?(:main, :less) # => false
.content
Lorem
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment