mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
28f88e0074
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.
25 lines
537 B
Ruby
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
|