Module: CFT
- Defined in:
- lib/cft.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
40 41 42 43 |
# File 'lib/cft.rb', line 40 def compile(template) template = template.read if template.respond_to?(:read) Source.context.call("cft.precompile", template) end |
.context_for(template) ⇒ Object
45 46 47 |
# File 'lib/cft.rb', line 45 def context_for(template) ExecJS.compile("var render = #{compile(template)}") end |
.render(template, locals = {}) ⇒ Object
49 50 51 |
# File 'lib/cft.rb', line 49 def render(template, locals = {}) context_for(template).call("render", locals) end |