Module: Ssejs

Defined in:
lib/ssejs.rb

Class Method Summary collapse

Class Method Details

.render(template, vars = {}, libs = []) ⇒ Object



5
6
7
8
9
10
11
12
13
14
# File 'lib/ssejs.rb', line 5

def self.render(template, vars = {}, libs = [])
  V8::Context.new do |cxt|
    cxt.eval('var window = this;')
    cxt.load("#{File.dirname(__FILE__)}/ejs.js")
    libs.each {|lib| cxt.load(lib) }
    cxt['vars'] = vars
    cxt['template'] = template
    return cxt.eval("new EJS({text: template}).render(vars)")
  end
end