Class: Plasma::PlasmaEngine

Inherits:
Object show all
Defined in:
lib/extras/plasma_engine.rb

Defined Under Namespace

Modules: Mixin

Class Method Summary collapse

Class Method Details

.compile_template(io, name, mod) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/extras/plasma_engine.rb', line 3

def self.compile_template(io, name, mod)
  path = File.expand_path(io.path)
  code = io.read.gsub(/"/, '\"')
  plasma = <<-interpret
    def #{name}
      Plasma::Interpreter.interpret("#{code}")
    end
  interpret

  m = mod.is_a?(Module) ? :module_eval : :instance_eval
  mod.__send__(m, plasma, path || '(plasma)')
  name
end