Module: Eco

Defined in:
lib/eco.rb

Defined Under Namespace

Modules: Source

Class Method Summary collapse

Class Method Details

.compile(template) ⇒ Object



38
39
40
41
# File 'lib/eco.rb', line 38

def compile(template)
  template = template.read if template.respond_to?(:read)
  Source.context.call("eco.precompile", template)
end

.context_for(template) ⇒ Object



43
44
45
# File 'lib/eco.rb', line 43

def context_for(template)
  ExecJS.compile("var render = #{compile(template)}")
end

.render(template, locals = {}) ⇒ Object



47
48
49
# File 'lib/eco.rb', line 47

def render(template, locals = {})
  context_for(template).call("render", locals)
end

.versionObject



34
35
36
# File 'lib/eco.rb', line 34

def version
  Source.version
end