Class: Merb::Template::Erubis
- Defined in:
- lib/merb-core/controller/template.rb
Defined Under Namespace
Modules: Mixin
Class Method Summary collapse
-
.compile_template(io, name, locals, mod) ⇒ Object
private
Parameters io<#path>:: An IO containing the full path of the template.
Class Method Details
.compile_template(io, name, locals, mod) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Parameters
- io<#path>
-
An IO containing the full path of the template.
- name<String>
-
The name of the method that will be created.
- locals<Array>
-
A list of locals to assign from the args passed into the compiled template.
- mod<Module>
-
The module that the compiled method will be placed into.
193 194 195 196 197 198 199 200 201 202 203 204 205 |
# File 'lib/merb-core/controller/template.rb', line 193 def self.compile_template(io, name, locals, mod) template = ::Erubis::BlockAwareEruby.new(io.read) _old_verbose, $VERBOSE = $VERBOSE, nil assigns = locals.inject([]) do |assigns, local| assigns << "#{local} = _locals[#{local.inspect}]" end.join(";") code = "def #{name}(_locals={}); #{assigns}; #{template.src}; end" mod.module_eval code, File.(io.path) $VERBOSE = _old_verbose name end |