Module: Flok::UserCompiler

Defined in:
lib/flok/user_compiler.rb

Class Method Summary collapse

Class Method Details

.compile(rb_src) ⇒ Object

Compile a ruby file containing flok controller definitions (from the user)



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/flok/user_compiler.rb', line 9

def self.compile rb_src
  #Execute code in this context, the context will hold all the information
  #that is used to then generate code
  context = UserCompilerContext.new
  context.instance_eval(rb_src, __FILE__, __LINE__)

  @src = ""
  ctable_erb = File.read File.join(File.dirname(__FILE__), "./user_compiler_templates/ctable.js.erb")
  ctable_renderer = ERB.new(ctable_erb)
  @src << ctable_renderer.result(context.get_binding)
  
  return @src
end