Class Merb::Template::Erubis
In: merb-core/lib/merb-core/controller/template.rb
Parent: Object

Methods

Classes and Modules

Module Merb::Template::Erubis::Mixin

Public Class methods

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[Symbol]>: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.

:api: private

[Source]

     # File merb-core/lib/merb-core/controller/template.rb, line 198
198:     def self.compile_template(io, name, locals, mod)
199:       template = ::Erubis::BlockAwareEruby.new(io.read)
200:       _old_verbose, $VERBOSE = $VERBOSE, nil
201:       assigns = locals.inject([]) do |assigns, local|
202:         assigns << "#{local} = _locals[#{local.inspect}]"
203:       end.join(";")
204:       
205:       code = "def #{name}(_locals={}); #{assigns}; #{template.src}; end"
206:       mod.module_eval code, File.expand_path(io.path)
207:       $VERBOSE = _old_verbose
208:       
209:       name
210:     end

[Validate]