Created
May 9, 2012 15:15
-
-
Save reagent/2645366 to your computer and use it in GitHub Desktop.
Grumble grumble...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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