1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/actionview/lib/action_view/template/handlers/builder.rb
Aaron Patterson 28f88e0074
Pass source to template handler and deprecate old style handler
This commit passes the mutated source to the template handler as a
parameter and deprecates the old handlers.  Old handlers required that
templates contain a reference to mutated source code, but we would like
to make template objects "read only".  This change lets the template
remain "read only" while still giving template handlers access to the
source code after mutations.
2019-02-01 16:19:53 -08:00

25 lines
537 B
Ruby

# frozen_string_literal: true
module ActionView
module Template::Handlers
class Builder
class_attribute :default_format, default: :xml
def call(template, source)
require_engine
"xml = ::Builder::XmlMarkup.new(:indent => 2);" \
"self.output_buffer = xml.target!;" +
source +
";xml.target!;"
end
private
def require_engine # :doc:
@required ||= begin
require "builder"
true
end
end
end
end
end