aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/new_base/renderer.rb
blob: eb3c8b808d134c204bad797284fe198f84665acd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
module ActionController
  module Renderer
    
    def render(options)
      _process_options(options)
      
      self.response_body = render_to_string(options)
    end
    
    def render_to_string(options)
      self.formats = [:html]
      
      if options.key?(:text)
        text = options.delete(:text)

        case text
        when nil then " "
        else          text.to_s
        end
      elsif options.key?(:template)
        template = options.delete(:template)
        
        super(template)
      end
    end
    
    private
    def _process_options(options)
      if status = options.delete(:status)
        response.status = status.to_i
      end
    end
  end
end