Module: Eco
- Defined in:
- lib/eco.rb
Defined Under Namespace
Modules: Source
Class Method Summary collapse
- .compile(template) ⇒ Object
- .context_for(template) ⇒ Object
- .render(template, locals = {}) ⇒ Object
- .version ⇒ Object
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 |