Module: CrumbsHelper
- Defined in:
- app/helpers/crumbs_helper.rb
Instance Method Summary collapse
-
#breadcrumb(crumbs = {}) ⇒ Object
breadcrumb(“Home” => “/”, “Blog” => [:site, :blog], @post.title => request.path ).
Instance Method Details
#breadcrumb(crumbs = {}) ⇒ Object
breadcrumb(“Home” => “/”, “Blog” => [:site, :blog], @post.title => request.path )
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/helpers/crumbs_helper.rb', line 5 def (crumbs = {}) crumbs = crumbs.to_a buff = "" buff << '<ul class="breadcrumb">' active = crumbs.pop crumbs.each do |title, path| path = !path.is_a?(String) ? polymorphic_path(path) : h(path) buff << <<-eos <li itemscope itemtype="http://data-vocabulary.org/Breadcrumb"> <a itemprop="url" href="#{path}"> <span itemprop="title">#{h(title)}</span> </a> <span class="divider">/</span> </li> eos end title, path = active path = !path.is_a?(String) ? polymorphic_path(path) : h(path) buff << <<-eos <li itemscope itemtype="http://data-vocabulary.org/Breadcrumb" class="active"> <a itemprop="url" href="#{path}"> <span itemprop="title">#{h(title)}</span> </a> </li> eos buff << '</ul>' content_for( :breadcrumb, buff.html_safe ) nil end |