Thanks to visit codestin.com
Credit goes to github.com

Skip to content

AlexWayfer/flame-menu

Repository files navigation

Flame Menu

Cirrus CI - Base Branch Build Status Coveralls Inline docs License Gem

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).

Installation

Add this line to your application's Gemfile:

gem 'flame-menu'

And then execute:

bundle install

Or install it yourself as:

gem install flame-menu

Usage

# 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 %>

Development

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.

Contributing

Bug reports and pull requests are welcome on GitHub.

License

The gem is available as open source under the terms of the MIT License.

About

Menu for Flame application

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages