summaryrefslogtreecommitdiff
path: root/app/helpers/wiki_helper.rb
blob: 3e3f6246fc5ef033f939ffd18afc6463bfbbbfea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
module WikiHelper
  # Produces a pure text breadcrumb for a given page.
  #
  # page_slug - The slug of a WikiPage object.
  #
  # Returns a String composed of the capitalized name of each directory and the
  # capitalized name of the page itself.
  def breadcrumb(page_slug)
    page_slug.split('/').
      map { |dir_or_page| WikiPage.unhyphenize(dir_or_page).capitalize }.
      join(' / ')
  end
end