Module: Rtml::Controller::RenderHelpers

Defined in:
lib/rtml/controller/render_helpers.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



26
27
28
# File 'lib/rtml/controller/render_helpers.rb', line 26

def self.included(base)
  base.send(:alias_method_chain, :render, :rtml_option)
end

Instance Method Details

#render_with_rtml_option(options = nil, extra_options = {}, &block) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/rtml/controller/render_helpers.rb', line 2

def render_with_rtml_option(options = nil, extra_options = {}, &block)
  if (h = options).is_a?(Hash) || (h = extra_options).is_a?(Hash)
    h = extra_options if !h.key?(:rtml) && extra_options.is_a?(Hash)
    if rtml_action = h.delete(:rtml)
      if rtml_helpers.respond_to?(rtml_action)
        request.format = :rtml
        rtml_helpers.send(rtml_action)
        set_rtml_headers
        response.template.template_format = :rtml
        tml = rtml_document.to_tml
        if Rtml.configuration.log_tml
          Rails.logger.debug tml
        end
        return render_without_rtml_option(h.merge(:text => tml))
      else
        raise Rtml::Errors::UnknownRtmlAction,
              "No RTML action responded to #{rtml_action}. RTML actions: #{rtml_actions.sort.to_sentence(:locale => :en)}",
              caller
      end
    end
  end
  render_without_rtml_option(options, extra_options, &block)
end