Module: Ice::EcoTemplate

Defined in:
lib/ice/eco_template/base.rb,
lib/ice/eco_template/handler.rb,
lib/ice/eco_template/generated_helpers.rb

Defined Under Namespace

Modules: GeneratedHelpers Classes: Handler

Class Method Summary collapse

Class Method Details

.convert_template(template_text, vars = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/ice/eco_template/base.rb', line 8

def self.convert_template(template_text, vars = {})
  V8::C::Locker() do
  context = V8::Context.new
  context.eval(open "#{File.dirname(__FILE__)}/../../../js/lib/path-helper.js")

  IceJavascriptHelpers.each do |helper|
    context.eval(helper)
  end
  IceCoffeescriptHelpers.each do |helper|
    context.eval CoffeeScript.compile(helper, :bare => true)
  end

  context.eval CoffeeScript.compile(GeneratedHelpers.get_routes, :bare => true)
  context.eval(Eco::Source.combined_contents)
  template = context["eco"]["compile"].call(template_text)

  template.call(vars.to_ice)
  end
end