mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Make renderer configurable
This commit is contained in:
parent
28525b4cca
commit
424070574d
4 changed files with 10 additions and 2 deletions
|
@ -5,6 +5,8 @@ require "nokogiri"
|
|||
module ActiveText
|
||||
extend ActiveSupport::Autoload
|
||||
|
||||
mattr_accessor(:renderer)
|
||||
|
||||
autoload :Attachable
|
||||
autoload :Attachment
|
||||
autoload :Attribute
|
||||
|
|
|
@ -24,7 +24,7 @@ module ActiveText
|
|||
private
|
||||
def trix_attachment_content
|
||||
if partial_path = attachable.try(:to_trix_content_attachment_partial_path)
|
||||
ApplicationRenderer.render(partial: partial_path, object: self, as: model_name.element)
|
||||
ActiveText.renderer.render(partial: partial_path, object: self, as: model_name.element)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -48,7 +48,7 @@ module ActiveText
|
|||
def to_html
|
||||
render_attachments do |attachment|
|
||||
attachment.node.tap do |node|
|
||||
node.inner_html = ApplicationController.render(attachment)
|
||||
node.inner_html = ActiveText.renderer.render(attachment)
|
||||
end
|
||||
end.to_html
|
||||
end
|
||||
|
|
|
@ -30,5 +30,11 @@ module ActiveText
|
|||
helper ActiveText::TagHelper
|
||||
end
|
||||
end
|
||||
|
||||
initializer "active_text.config" do
|
||||
config.after_initialize do |app|
|
||||
ActiveText.renderer ||= ApplicationController.renderer
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue