def _template_for(context, content_type, controller=nil, template=nil, locals=[])
tmp = self.class._templates_for[[context, content_type, controller, template, locals]]
return tmp if tmp
template_method, template_location = nil, nil
if template.is_a?(String) && template =~ %r{^/}
template_location = self._absolute_template_location(template, content_type)
return [_template_method_for(template_location, locals), template_location]
end
self.class._template_roots.reverse_each do |root, template_meth|
if template
template_location = root / self.send(template_meth, template, content_type, nil)
else
template_location = root / self.send(template_meth, context, content_type, controller)
end
break if template_method = _template_method_for(template_location.to_s, locals)
end
ret = [template_method, template_location.to_s]
unless Merb::Config[:reload_templates]
self.class._templates_for[[context, content_type, controller, template, locals]] = ret
end
ret
end