Class: Spirit::Render::Navigation
- Defined in:
- lib/spirit/render/templates/navigation.rb
Overview
Keeps track of document sections and renders a navigation bar.
Instance Method Summary collapse
-
#append(heading, name) ⇒ void
Adds a new section.
-
#initialize ⇒ Navigation
constructor
Creates a new navigation bar.
-
#render(locals = {}) ⇒ Object
Renders the navigation bar in HTML.
Constructor Details
#initialize ⇒ Navigation
Creates a new navigation bar.
14 15 16 |
# File 'lib/spirit/render/templates/navigation.rb', line 14 def initialize @sections = {} end |
Instance Method Details
#append(heading, name) ⇒ void
This method returns an undefined value.
Adds a new section.
22 23 24 |
# File 'lib/spirit/render/templates/navigation.rb', line 22 def append(heading, name) @sections[name] = heading end |
#render(locals = {}) ⇒ Object
Renders the navigation bar in HTML.
27 28 29 |
# File 'lib/spirit/render/templates/navigation.rb', line 27 def render(locals={}) super locals.merge(sections: @sections) end |