Class: Gollum::Macro::Navigation
- Inherits:
-
Gollum::Macro
- Object
- Gollum::Macro
- Gollum::Macro::Navigation
- Defined in:
- lib/gollum-lib/macro/navigation.rb
Instance Method Summary collapse
Methods inherited from Gollum::Macro
Constructor Details
This class inherits a constructor from Gollum::Macro
Instance Method Details
#render(title = "Navigate in the TOC", toc_root_path = ::File.dirname(@page.path), full_path = false) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/gollum-lib/macro/navigation.rb', line 5 def render(title = "Navigate in the TOC", toc_root_path = ::File.dirname(@page.path), full_path = false) if @wiki.pages.size > 0 list_items = @wiki.pages.map do |page| if page.url_path.start_with?(toc_root_path) path_display = full_path ? page.url_path_display : page.url_path_display.sub(toc_root_path.gsub("-", " "), "").sub(/^\//,'') "<li><a href=\"/#{page.url_path}\">#{path_display}</a></li>" end end result = "<ul>#{list_items.join}</ul>" end "<div class=\"toc\"><div class=\"toc-title\">#{title}</div>#{result}</div>" end |