Module: Ice::Handlers::Eco

Defined in:
lib/ice/handlers/eco/handler.rb

Class Method Summary collapse

Class Method Details

.call(template) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/ice/handlers/eco/handler.rb', line 19

def self.call(template)
  <<-ECO
    template_source = <<-ECO_TEMPLATE
      #{template.source}
    ECO_TEMPLATE

    #{Base.variables}

    Ice::Handlers::Eco.convert_template(template_source, variables.merge(local_assigns))
  ECO
end

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



8
9
10
11
12
13
14
15
16
17
# File 'lib/ice/handlers/eco/handler.rb', line 8

def self.convert_template(template_text, vars = {})
  Base.convert_template(template_text) do |context|
    helpers = "#{File.dirname(__FILE__)}/../../../../js/lib/eco-path-helper.js"

    context.eval(open(helpers).read)
    context.eval(::Eco::Source.combined_contents)
    template = context["eco"]["compile"].call(template_text)
    template.call(vars.to_ice)
  end
end