Class: Nagoro::Pipe::Compile

Inherits:
Base
  • Object
show all
Defined in:
lib/nagoro/pipe/compile.rb

Instance Method Summary collapse

Methods inherited from Base

#append, #doctype, #initialize, #tag, #tag_end, #tag_start, #tag_with, #text

Constructor Details

This class inherits a constructor from Nagoro::Pipe::Base

Instance Method Details

#compile(template) ⇒ Object



23
24
25
26
27
# File 'lib/nagoro/pipe/compile.rb', line 23

def compile(template)
  template = template.read if template.respond_to?(:read)
  copy = template.gsub('`', '\\\\`')
  compile!(copy)
end

#instruction(name, instruction) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/nagoro/pipe/compile.rb', line 4

def instruction(name, instruction)
  case name
  when 'r'
    append("`;#{instruction}; _out_ << %Q`")
  when 'ro'
    append("`;_out_ << (#{instruction}); _out_ << %Q`")
  when 'h'
    append("`;_out_ << h(#{instruction}); _out_ << %Q`")
  when 'end'
    append("`;end; _out_ << %Q`")
  else
    append("<?#{name} #{instruction.strip} ?>")
  end
end

#resultObject



19
20
21
# File 'lib/nagoro/pipe/compile.rb', line 19

def result
  "_out_ = []; _out_ << %Q`#{super}`; _out_.join"
end