Class: Spirit::Render::Processors::HeadersProcessor

Inherits:
Base
  • Object
show all
Defined in:
lib/spirit/render/processors/headers_processor.rb

Overview

In-charge of headers, navigation bar, and nesting. Depends on renderer#navigation and renderer#nesting

Instance Method Summary collapse

Methods inherited from Base

events, inherited, #invoke_callbacks_for, process

Constructor Details

#initialize(renderer, *args) ⇒ HeadersProcessor

Returns a new instance of HeadersProcessor.



11
12
13
14
15
# 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

Instance Method Details

#header(text, level) ⇒ String

Increases all header levels by one and keeps a navigation bar.

Returns:

  • (String)

    rendered html



19
20
21
22
23
24
# 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