Skip to content

Instantly share code, notes, and snippets.

@reagent
Created May 9, 2012 15:15
Show Gist options
  • Save reagent/2645366 to your computer and use it in GitHub Desktop.
Save reagent/2645366 to your computer and use it in GitHub Desktop.
Grumble grumble...
class Breadcrumb
include ActionView::Helpers::TagHelper
def initialize
@crumbs = []
end
def append(name, link)
@crumbs << Breadcrumb::Crumb.new(name, link)
end
def to_html(wrapper_classes = nil, item_classes = nil)
content_tag :ul, :class => wrapper_classes do
@crumbs.map {|c| c.to_html(item_classes) }.join
end
end
class Crumb
include ActionView::Helpers::TagHelper
def initialize(name, link)
@name = name
@link = link
end
def to_html(classes = nil)
content_tag :li, link_to(@name, @link, :class => classes)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment