aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJavan Makhmali <javan@javan.us>2018-10-03 14:41:47 -0400
committerJavan Makhmali <javan@javan.us>2018-10-03 14:41:47 -0400
commit30443121286c3bb970d4d24bf7f24472498e9633 (patch)
tree6799fe7cc8aaabd6bfa35c8dfc75a11eb7f4e332 /lib
parent7a993324342d5542dcb40902eed097f7eaac3f1b (diff)
downloadrails-30443121286c3bb970d4d24bf7f24472498e9633.tar.gz
rails-30443121286c3bb970d4d24bf7f24472498e9633.tar.bz2
rails-30443121286c3bb970d4d24bf7f24472498e9633.zip
Move attachment rendering to a helper
Fixes #5
Diffstat (limited to 'lib')
-rw-r--r--lib/action_text/content.rb17
-rw-r--r--lib/action_text/engine.rb4
2 files changed, 3 insertions, 18 deletions
diff --git a/lib/action_text/content.rb b/lib/action_text/content.rb
index 71d9e98657..4061613e35 100644
--- a/lib/action_text/content.rb
+++ b/lib/action_text/content.rb
@@ -81,23 +81,8 @@ module ActionText
fragment.to_html
end
- def to_rendered_html
- render_attachments do |attachment|
- attachment.node.tap do |node|
- node.inner_html = ActionText.renderer.render(attachment)
- end
- end.render_attachment_galleries do |attachment_gallery|
- ActionText.renderer.render(layout: attachment_gallery, object: attachment_gallery, formats: "html") do
- attachment_gallery.attachments.map do |attachment|
- attachment.node.inner_html = ActionText.renderer.render(attachment)
- attachment.to_html
- end.join("").html_safe
- end
- end.to_html
- end
-
def to_rendered_html_with_layout
- ActionText.renderer.render(partial: "action_text/content/layout", locals: { document: to_rendered_html })
+ ActionText.renderer.render(partial: "action_text/content/layout", locals: { content: self })
end
def to_s
diff --git a/lib/action_text/engine.rb b/lib/action_text/engine.rb
index 71db6d6a26..4055bbbb29 100644
--- a/lib/action_text/engine.rb
+++ b/lib/action_text/engine.rb
@@ -25,7 +25,7 @@ module ActionText
initializer "action_text.helper" do
ActiveSupport.on_load(:action_controller_base) do
- helper ActionText::TagHelper
+ helper ActionText::Engine.helpers
end
end
@@ -33,7 +33,7 @@ module ActionText
config.after_initialize do |app|
ActionText.renderer ||= ApplicationController.renderer
- # FIXME: ApplicationController should have a per-request specific renderer
+ # FIXME: ApplicationController should have a per-request specific renderer
# that's been set with the request.env env, and ActionText should just piggyback off
# that by default rather than doing this work directly.
ApplicationController.before_action do