Module: Ice::Handlers::Base

Defined in:
lib/ice/handlers/base.rb

Class Method Summary collapse

Class Method Details

.convert_template(template_text) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/ice/handlers/base.rb', line 21

def self.convert_template(template_text)
  V8::C::Locker() do
    context = V8::Context.new

    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)
    yield context

  end
end

.variablesObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/ice/handlers/base.rb', line 6

def self.variables
  <<-VARIABLES
    variable_names = controller.instance_variable_names
    variable_names -= %w[@template]
    if controller.respond_to?(:protected_instance_variables)
      variable_names -= controller.protected_instance_variables
    end

    variables = {}
    variable_names.each do |name|
      variables[name.sub(/^@/, "")] = controller.instance_variable_get(name)
    end
  VARIABLES
end