Class: Spirit::Render::Navigation

Inherits:
Template
  • Object
show all
Defined in:
lib/spirit/render/templates/navigation.rb

Overview

Keeps track of document sections and renders a navigation bar.

Instance Method Summary collapse

Constructor Details

#initializeNavigation

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.

Parameters:

  • heading (String)

    section heading

  • name (String)

    anchor name



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