Class: Soy::Renderer

Inherits:
Object
  • Object
show all
Defined in:
lib/soy/renderer.rb

Overview

Runs the template through ERB and generates HTML from it, within optional layout.

Instance Method Summary collapse

Constructor Details

#initialize(template, layout) ⇒ Renderer

template, Soy::File instance layout, Soy::File instance



12
13
14
15
16
17
# File 'lib/soy/renderer.rb', line 12

def initialize(template, layout)
  @template = template
  @layout = layout

  @page = Page.new
end

Instance Method Details

#renderObject



19
20
21
22
23
24
25
# File 'lib/soy/renderer.rb', line 19

def render
  out = _render(@template)
  out = convert_template(out)
  out = _render(@layout) { out }
  out = out.gsub(/^\s+$/, "")
  out.gsub(/\A\n/, "")
end