aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/template_handlers/builder.rb
blob: a9fc069f884aea358d2adbce83de09472406ed80 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
require 'builder'

module ActionView
  module TemplateHandlers
    class Builder < TemplateHandler
      def compile(template)
        content_type_handler = (@view.send!(: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"
      end
    end
  end
end