1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/actionpack/lib/action_view/template_handlers/builder.rb
Michael Koziarski e6de95889d * Pass around handler instances, not their classes [Koz]
* Move compilation, rendering and 'compilable?' checks into the Handlers [Koz]
 * Remove delegate_* methods as the handler is now an instance [Koz]


git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8624 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2008-01-11 04:45:06 +00:00

29 lines
719 B
Ruby

require 'builder'
module ActionView
module TemplateHandlers
class Builder < TemplateHandler
def self.line_offset
2
end
def self.compilable?
true
end
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
def cache_fragment(block, name = {}, options = nil)
@view.fragment_for(block, name, options) do
eval('xml.target!', block.binding)
end
end
end
end
end