class ActionView::Base
:nodoc:
def convert_template_into_ruby_code(template)
def convert_template_into_ruby_code(template) #ERB.new(template, nil, @@erb_trim_mode).src return _convert_template(template) end
def create_template_source(extension, template, render_symbol, locals)
def create_template_source(extension, template, render_symbol, locals) if template_requires_setup?(extension) body = case extension.to_sym when :rxml, :builder content_type_handler = (controller.respond_to?(:response) ? "controller.response" : "controller") "#{content_type_handler}.content_type ||= Mime::XML\n" + "xml = Builder::XmlMarkup.new(:indent => 2)\n" + template + "\nxml.target!\n" when :rjs "controller.response.content_type ||= Mime::JS\n" + "update_page do |page|\n#{template}\nend" end else #body = ERB.new(template, nil, @@erb_trim_mode).src body = convert_template_into_ruby_code(template) end # @@template_args[render_symbol] ||= {} locals_keys = @@template_args[render_symbol].keys | locals @@template_args[render_symbol] = locals_keys.inject({}) { |h, k| h[k] = true; h } # locals_code = "" locals_keys.each do |key| locals_code << "#{key} = local_assigns[:#{key}]\n" end # "def #{render_symbol}(local_assigns)\n#{locals_code}#{body}\nend" end
def create_template_source(extension, template, render_symbol, locals)
def create_template_source(extension, template, render_symbol, locals) if template_requires_setup?(extension) body = case extension.to_sym when :rxml "controller.response.content_type ||= 'application/xml'\n" + "xml = Builder::XmlMarkup.new(:indent => 2)\n" + template when :rjs "controller.response.content_type ||= 'text/javascript'\n" + "update_page do |page|\n#{template}\nend" end else #body = ERB.new(template, nil, @@erb_trim_mode).src body = convert_template_into_ruby_code(template) end # @@template_args[render_symbol] ||= {} locals_keys = @@template_args[render_symbol].keys | locals @@template_args[render_symbol] = locals_keys.inject({}) { |h, k| h[k] = true; h } # locals_code = "" locals_keys.each do |key| locals_code << "#{key} = local_assigns[:#{key}]\n" end # "def #{render_symbol}(local_assigns)\n#{locals_code}#{body}\nend" end
def create_template_source(extension, template, render_symbol, locals)
def create_template_source(extension, template, render_symbol, locals) if template_requires_setup?(extension) body = case extension.to_sym when :rxml "xml = Builder::XmlMarkup.new(:indent => 2)\n" + "@controller.headers['Content-Type'] ||= 'application/xml'\n" + template when :rjs "@controller.headers['Content-Type'] ||= 'text/javascript'\n" + "update_page do |page|\n#{template}\nend" end else #body = ERB.new(template, nil, @@erb_trim_mode).src body = convert_template_into_ruby_code(template) end # @@template_args[render_symbol] ||= {} locals_keys = @@template_args[render_symbol].keys | locals @@template_args[render_symbol] = locals_keys.inject({}) { |h, k| h[k] = true; h } # locals_code = "" locals_keys.each do |key| locals_code << "#{key} = local_assigns[:#{key}] if local_assigns.has_key?(:#{key})\n" end # "def #{render_symbol}(local_assigns)\n#{locals_code}#{body}\nend" end