diff options
author | Javan Makhmali <javan@javan.us> | 2018-10-03 14:41:47 -0400 |
---|---|---|
committer | Javan Makhmali <javan@javan.us> | 2018-10-03 14:41:47 -0400 |
commit | 30443121286c3bb970d4d24bf7f24472498e9633 (patch) | |
tree | 6799fe7cc8aaabd6bfa35c8dfc75a11eb7f4e332 /app/helpers | |
parent | 7a993324342d5542dcb40902eed097f7eaac3f1b (diff) | |
download | rails-30443121286c3bb970d4d24bf7f24472498e9633.tar.gz rails-30443121286c3bb970d4d24bf7f24472498e9633.tar.bz2 rails-30443121286c3bb970d4d24bf7f24472498e9633.zip |
Move attachment rendering to a helper
Fixes #5
Diffstat (limited to 'app/helpers')
-rw-r--r-- | app/helpers/action_text/content_helper.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/app/helpers/action_text/content_helper.rb b/app/helpers/action_text/content_helper.rb new file mode 100644 index 0000000000..6d00eee648 --- /dev/null +++ b/app/helpers/action_text/content_helper.rb @@ -0,0 +1,24 @@ +module ActionText + module ContentHelper + def render_action_text_content(content) + content = content.render_attachments do |attachment| + unless attachment.in?(content.gallery_attachments) + attachment.node.tap do |node| + node.inner_html = render(attachment, in_gallery: false).chomp + end + end + end + + content = content.render_attachment_galleries do |attachment_gallery| + render(layout: attachment_gallery, object: attachment_gallery) do + attachment_gallery.attachments.map do |attachment| + attachment.node.inner_html = render(attachment, in_gallery: true).chomp + attachment.to_html + end.join("").html_safe + end.chomp + end + + content.to_html + end + end +end |