Module: Migajas

Defined in:
lib/migajas.rb,
lib/migajas/version.rb

Defined Under Namespace

Classes: Trail

Constant Summary collapse

VERSION =
"0.9.0".freeze

Instance Method Summary collapse

Instance Method Details

Public: List of breadcrumbs encountered in this request. Add to this list any breadcrumb as you go through your routing tree in the app:

Example

define do
  breadcrumbs << "Home"

  on "users" do
    breadcrumbs << "Users"

    on get do
      # render the list
    end

    on ":id" do |id|
      user = User[id]
      breadcrumbs << user.name

      # etc
    end
  end
end

This will automatically build a list with the following breadcrumbs:

[
  Migajas::Crumb.new("Home", "/"),
  Migajas::Crumb.new("Users", "/users"),
  Migajas::Crumb.new("Profile", "/users/5")
]

In the view you can, then:

<% breadcrumbs.each do |crumb| %>
  <li class="<%= "active" if crumb.current? %>">
    <a href="<%= crumb.url %>"><%= crumb.name %></a>
  </li>
<% end %>

Returns a Migajas::Trail.



43
44
45
# File 'lib/migajas.rb', line 43

def breadcrumbs
  env["app.breadcrumbs"] ||= Trail.new(env)
end