class Spirit::Render::Processors::HeadersProcessor
In-charge of headers, navigation bar, and nesting. Depends on renderer#navigation and renderer#nesting
Attributes
headers[RW]
nesting[RW]
Public Class Methods
new(renderer, *args)
click to toggle source
# File lib/spirit/render/processors/headers_processor.rb, line 11 def initialize(renderer, *args) renderer.nesting = @nesting = [] renderer.navigation = @navigation = Navigation.new @headers = Headers.new end
Public Instance Methods
header(text, level)
click to toggle source
Increases all header levels by one and keeps a navigation bar. @return [String] rendered html
# File lib/spirit/render/processors/headers_processor.rb, line 19 def header(text, level) h = headers.add(text, level += 1) navigation.append(text, h.name) if level == 2 nest h h.render end
Private Instance Methods
nest(h)
click to toggle source
Maintains the nesting
array. @param [Header] h
# File lib/spirit/render/processors/headers_processor.rb, line 32 def nest(h) nesting.pop until nesting.empty? or h.level > nesting.last.level nesting << h end