Module: ActionText::ContentHelper

Defined in:
actiontext/app/helpers/action_text/content_helper.rb

Instance Method Summary collapse

Instance Method Details

#render_action_text_attachments(content) ⇒ Object


20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'actiontext/app/helpers/action_text/content_helper.rb', line 20

def render_action_text_attachments(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.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
end

#render_action_text_content(content) ⇒ Object


12
13
14
# File 'actiontext/app/helpers/action_text/content_helper.rb', line 12

def render_action_text_content(content)
  sanitize_action_text_content(render_action_text_attachments(content))
end

#sanitize_action_text_content(content) ⇒ Object


16
17
18
# File 'actiontext/app/helpers/action_text/content_helper.rb', line 16

def sanitize_action_text_content(content)
  sanitizer.sanitize(content.to_html, tags: allowed_tags, attributes: allowed_attributes, scrubber: scrubber).html_safe
end