Fume::Nav
help build navigation for rails.
Installation
Add this line to your application's Gemfile:
gem 'fume-nav'
Usage
example
view.erb
<% @current = :edit %>
<%= fume_nav @current do |n| %>
<ul>
<%= n.li_tag :show do %>
<%= link_to 'show', link_path(@link) %>
<% end %>
<%= n.li_tag :edit do %>
<%= link_to 'edit', edit_link_path(@link) %>
<% end %>
</ul>
<% end %>
<%= fume_nav @current do |n| %>
<div class="dropdown">
<%= n.link_to :show, "link_1", root_path, class: "link" %>
<%= n.apply_content :edit do |active_class| %>
<%= link_to "link_2", root_path, class: "link #{active_class || 'default'}" %>
<% end %>
</div>
<% end %>
<%= fume_nav @current, active_class: "text-primary", inactive_class: "text-muted" do |n| %>
<div>
<%= n.link_to :show, "link_1", root_path %>
<%= n.link_to :edit, "link_2", root_path %>
</div>
<% end %>
output:
<ul>
<li>
<a href="/links/1">show</a>
</li>
<li class="active">
<a href="/links/1/edit">edit</a>
</li>
</ul>
<div class="dropdown">
<a class="link active" href="/">link_1</a>
<a class="link " href="/">link_2</a>
</div>
<div>
<a class="text-primary" href="/">link_1</a>
<a class="text-muted" href="/">link_2</a>
</div>
Options
<%= fume_nav(current_value, options) do |n| %>
// OOXX
<% end %>
OPTIONS:
active_class | the current active item class, default: 'active' |
hide_if_empty | don't output content html if not exist any subitem, default: true |
Contributing
- Fork it ( https://github.com/sunteya/fume-nav/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request