Method: Merb::Template.inline_template

Defined in:
lib/merb-core/controller/template.rb

.inline_template(io, locals = [], mod = Merb::InlineTemplates) ⇒ Object

Takes a template at a particular path and inlines it into a module and adds it to the METHOD_LIST table to speed lookup later.

Parameters

io<#path>

An IO that responds to #path (File or VirtualFile)

locals<Array>

A list of local names that should be assigned in the template method from the arguments hash. Defaults to [].

mod<Module>

The module to put the compiled method into. Defaults to Merb::InlineTemplates

Returns

Symbol

The name of the method that the template was compiled into.

Notes

Even though this method supports inlining into any module, the method must be available to instances of AbstractController that will use it.

:api: private



131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/merb-core/controller/template.rb', line 131

def inline_template(io, locals=[], mod = Merb::InlineTemplates)
  full_file_path = File.expand_path(io.path)
  engine_neutral_path = full_file_path.gsub(/\.[^\.]*$/, "")
  
  local_list = (SUPPORTED_LOCALS_LIST[engine_neutral_path] |= locals)
  ret = METHOD_LIST[engine_neutral_path] =
    engine_for(full_file_path).compile_template(io, 
    template_name(full_file_path), local_list, mod)
    
  io.close
  ret
end