Class: Spirit::Render::Processors::LayoutProcessor

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

Overview

Post-processes a layout in HAML.

Constant Summary collapse

TEMPLATE =
File.join VIEWS, 'layout.haml'

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

events, inherited, #invoke_callbacks_for, process

Constructor Details

#initialize(renderer, *args) ⇒ LayoutProcessor

Returns a new instance of LayoutProcessor.



13
14
15
16
17
# File 'lib/spirit/render/processors/layout_processor.rb', line 13

def initialize(renderer, *args)
  template  = File.read TEMPLATE
  @engine   = Haml::Engine.new template, HAML_CONFIG
  @renderer = renderer
end

Instance Attribute Details

#engineObject

Returns the value of attribute engine.



10
11
12
# File 'lib/spirit/render/processors/layout_processor.rb', line 10

def engine
  @engine
end

#rendererObject

Returns the value of attribute renderer.



10
11
12
# File 'lib/spirit/render/processors/layout_processor.rb', line 10

def renderer
  @renderer
end

Instance Method Details

#render(document) ⇒ Object



19
20
21
22
# File 'lib/spirit/render/processors/layout_processor.rb', line 19

def render(document)
  engine.render renderer,
    content: document.force_encoding('utf-8')
end