def partial(template, opts={})
template = template.to_s
kontroller = (m = template.match(/.*(?=\/)/)) ? m[0] : controller_name
template = "_#{File.basename(template)}"
template_method, template_location = _template_for(template, opts.delete(:format) || content_type, kontroller)
(@_old_partial_locals ||= []).push @_merb_partial_locals
if opts.key?(:with)
with = opts.delete(:with)
as = opts.delete(:as) || template_location.match(%r[.*/_([^\.]*)])[1]
@_merb_partial_locals = opts
sent_template = [with].flatten.map do |temp|
@_merb_partial_locals[as.to_sym] = temp
send(template_method)
end.join
else
@_merb_partial_locals = opts
if template_method && self.respond_to?(template_method)
sent_template = send(template_method)
else
raise TemplateNotFound, "Could not find template at #{template_location}.*"
end
end
@_merb_partial_locals = @_old_partial_locals.pop
sent_template
end