| | 6 | |
|---|
| | 7 | public |
|---|
| | 8 | def partial(template, opts={}) |
|---|
| | 9 | |
|---|
| | 10 | puts |
|---|
| | 11 | puts |
|---|
| | 12 | puts "Inside new partial" |
|---|
| | 13 | puts |
|---|
| | 14 | puts |
|---|
| | 15 | |
|---|
| | 16 | unless @_template_format |
|---|
| | 17 | @web_controller.choose_template_format(Merb.available_mime_types, {}) |
|---|
| | 18 | end |
|---|
| | 19 | |
|---|
| | 20 | template = @web_controller._cached_partials["#{template}.#{@_template_format}"] ||= |
|---|
| | 21 | @web_controller.send(:find_partial, template) |
|---|
| | 22 | |
|---|
| | 23 | if with = opts.delete(:with) |
|---|
| | 24 | as = opts.delete(:as) || template.match(/(.*\/_)([^\.]*)/)[2] |
|---|
| | 25 | @_merb_partial_locals = opts |
|---|
| | 26 | sent_template = [with].flatten.map do |temp| |
|---|
| | 27 | @_merb_partial_locals[as.to_sym] = temp |
|---|
| | 28 | send(template.gsub("/", "__").gsub(".", "_")) rescue "" |
|---|
| | 29 | end.join |
|---|
| | 30 | else |
|---|
| | 31 | @_merb_partial_locals = opts |
|---|
| | 32 | sent_template = send(template.gsub("/", "__").gsub(".", "_")) rescue nil |
|---|
| | 33 | end |
|---|
| | 34 | |
|---|
| | 35 | return sent_template if sent_template |
|---|
| | 36 | |
|---|
| | 37 | raise Merb::ControllerExceptions::TemplateNotFound, "No template matched at #{template}" |
|---|
| | 38 | end |
|---|
| | 39 | |
|---|
| | 40 | def method_missing(sym, *args, &blk) |
|---|
| | 41 | @_merb_partial_locals[sym] || @web_controller.send(sym, *args, &blk) rescue super |
|---|
| | 42 | end |
|---|
| | 43 | |
|---|