Navigation menu for Flame applications.
There are helper methods (like @menu.current),
but you have to write an HTML layout by yourself (as you want to).
Add this line to your application's Gemfile:
gem 'flame-menu'And then execute:
bundle installOr install it yourself as:
gem install flame-menu# controllers/site/_controller.rb
module MyApplication
module Site
class Controller < MyApplication::Controller
include Flame::Menu
## Automatic look-up for controllers like `Site::AboutController`
MENU_ITEMS = %i[
index
about
faq
].freeze
protected
## Must be defined, but can be simply `true` for public access
def available?(controller = self.class)
## Example:
# return false unless authenticated_account
# return true if controller::PERMISSION.nil?
#
# authenticated_account.split(',').include? controller::PERMISSION.to_s
end
end
end
end<% if @menu %>
<nav>
<%
@menu.current.ancestors.reverse.each do |parent|
items = parent.available
next if items.size < 2
%>
<% items.each do |item| %>
<a
href="<%= path_to item.controller %>"
class="<%= 'selected' if item.current? %>"
><%=
t.site.header.nav[parent.key][item.key]
%></a>
<% end %>
<% end %>
</nav>
<% end %>After checking out the repo, run bundle install to install dependencies.
Then, run toys rspec to run the tests.
To install this gem onto your local machine, run toys gem install.
To release a new version, run toys gem release %version%.
See how it works here.
Bug reports and pull requests are welcome on GitHub.
The gem is available as open source under the terms of the MIT License.