Module: Nyara::View::ERB

Defined in:
lib/nyara/view_handlers/erb.rb

Class Method Summary collapse

Class Method Details

.src(template) ⇒ Object


6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/nyara/view_handlers/erb.rb', line 6

def self.src template
  @erb_compiler ||= begin
    c            = ::ERB::Compiler.new '<>' # trim mode
    c.pre_cmd    = ["_erbout = @_nyara_view.out"]
    c.put_cmd    = "_erbout.push"   # after newline
    c.insert_cmd = "_erbout.push"   # before newline
    c.post_cmd   = ["_erbout.join"]
    c
  end
  src, enc = @erb_compiler.compile template
  # todo do sth with enc?
  src
end