Parent

Files

Padrino::Helpers::Breadcrumb

Attributes

home[RW]
items[RW]

Public Class Methods

new() click to toggle source

initialize breadcrumbs with default value

@example

before do
  @breadcrumbs = breadcrumbs.new
end

@api public

# File lib/padrino-helpers/breadcrumb_helpers.rb, line 19
def initialize
  reset!
end

Public Instance Methods

<<(name, url, caption, options = {}) click to toggle source
Alias for: add
add(name, url, caption, options = {}) click to toggle source

Add a new breadcrumbs

@param [String] name

The name of resource.

@param [Symbol] name

The name of resource.

@param [String] url

The url href.

@param [String] caption

The text caption.

@param [Hash] options

The HTML options to include in li.

@example

breadcrumbs.add "foo", "/foo", "Foo Link", :id => "foo-id"
breadcrumbs.add :foo, "/foo", "Foo Link", :class => "foo-class"

@api public

# File lib/padrino-helpers/breadcrumb_helpers.rb, line 101
def add(name, url, caption, options = {})
  items << {
    :name    => name.to_sym,
    :url     => url.to_s,
    :caption => caption.to_s.humanize.html_safe,
    :options => options
  }
end
Also aliased as: <<
del(name) click to toggle source

Remove a Breadcrumbs

@param [String] name

The name of resource to delete from breadcrumbs list

@param [Symbol] name

The name of resource to delete from breadcrumbs list

@example

breadcrumbs.del "foo"
breadcrumbs.del :foo

@api public

# File lib/padrino-helpers/breadcrumb_helpers.rb, line 126
def del(name)
  items.delete_if { |item| item[:name] == name.to_sym }
end
reset() click to toggle source

Reset breadcrumbs to default or personal home

@example

breadcrumbs.reset

@api public

# File lib/padrino-helpers/breadcrumb_helpers.rb, line 57
def reset
  self.items = []
  self.items << home
end
reset!() click to toggle source

Reset breadcrumbs to default home

@example

breadcrumbs.reset!

@api public

# File lib/padrino-helpers/breadcrumb_helpers.rb, line 69
def reset!
  self.home = {
    :name    => :home,
    :url     => DEFAULT_URL,
    :caption => DEFAULT_CAPTION,
    :options => {}
  }
  reset
end
set_home(url, caption, options = {}) click to toggle source

Set the custom home (Parent) link

@param [String] url

The url href

@param [String] caption

The  text caption.

@param [Hash] options

The HTML options to include in li.

@example

breadcrumbs.set_home "/HomeFoo", "Foo Home", :id => "home-breadcrumb"

@api public

# File lib/padrino-helpers/breadcrumb_helpers.rb, line 40
def set_home(url, caption, options = {})
  self.home = {
    :url     => url.to_s,
    :caption => caption.to_s.humanize.html_safe,
    :name    => :home,
    :options => options
  }
  reset
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.