Class: Gollum::DescendantTree::TreeRenderer
- Inherits:
-
Object
- Object
- Gollum::DescendantTree::TreeRenderer
- Defined in:
- lib/gollum/descendant_tree/tree_renderer.rb
Instance Method Summary collapse
-
#initialize ⇒ TreeRenderer
constructor
A new instance of TreeRenderer.
- #render(tree) ⇒ Object
Constructor Details
#initialize ⇒ TreeRenderer
Returns a new instance of TreeRenderer.
7 8 9 |
# File 'lib/gollum/descendant_tree/tree_renderer.rb', line 7 def initialize @previous_nest_index = 0 end |
Instance Method Details
#render(tree) ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/gollum/descendant_tree/tree_renderer.rb', line 11 def render(tree) output = "<ul class='tree'>\n" tree.each do |page| output += nest_for(page) if page[:nest_index] != 0 output += "<li><a href='/#{page[:url_path]}'>#{page[:title].titleize}</a>" end output += "</ul></li>\n" output += "</ul>\n" output end |