aboutsummaryrefslogblamecommitdiffstats
path: root/actionpack/lib/action_view/template_handlers/builder.rb
blob: 2d413490bd9ddcbc44c336880a84f44fc328fdc7 (plain) (tree)
1
2
3
4
5
6
7
8
9
10




                                   

                        
                           

                                                           
                           
                         
         





                                                         


       
require 'builder'

module ActionView
  module TemplateHandlers
    class Builder < TemplateHandler
      include Compilable

      def compile(template)
        "controller.response.content_type ||= Mime::XML;" +
          "xml = ::Builder::XmlMarkup.new(:indent => 2);" +
          template.source +
          ";xml.target!;"
      end

      def cache_fragment(block, name = {}, options = nil)
        @view.fragment_for(block, name, options) do
          eval('xml.target!', block.binding)
        end
      end
    end
  end
end