Last active
June 10, 2018 09:35
-
-
Save dux/248d48df5e0526cb0c869c6c8d8deb8b to your computer and use it in GitHub Desktop.
Html menu builder helper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
menu = HtmlMenu.new request.path | |
menu.add 'Home', '/' | |
menu.add 'People', '/people', lambda { |path| path.index('peor') } | |
menu.add 'Jobs', '/jbos' | |
menu.to_a -> [["Home", "/", false], ["People", "/people", true], ["Jobs", "/jbos", false]] | |
menu.to_h -> [{:name=>"Home", :path=>"/", :active=>true}, {:name=>"People", :path=>"/people", :active=>false}, {:name=>"Jobs", :path=>"/jbos", :active=>false}] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment