Module: ActionText::ContentHelper
- Included in:
- Content
- Defined in:
- app/helpers/action_text/content_helper.rb
Instance Method Summary collapse
-
#render_action_text_attachment(attachment, locals: {}) ⇒ Object
:nodoc:.
- #render_action_text_attachments(content) ⇒ Object
- #render_action_text_content(content) ⇒ Object
- #sanitize_action_text_content(content) ⇒ Object
- #sanitize_content_attachment(content_attachment) ⇒ Object
- #sanitizer_allowed_attributes ⇒ Object
- #sanitizer_allowed_tags ⇒ Object
Instance Method Details
#render_action_text_attachment(attachment, locals: {}) ⇒ Object
:nodoc:
52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'app/helpers/action_text/content_helper.rb', line 52 def (, locals: {}) # :nodoc: = { locals: locals, object: , partial: } if .respond_to?(:to_attachable_partial_path) [:partial] = .to_attachable_partial_path end if .respond_to?(:model_name) [:as] = .model_name.element end render(**).chomp end |
#render_action_text_attachments(content) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'app/helpers/action_text/content_helper.rb', line 35 def (content) content. do || unless .in?(content.) .node.tap do |node| node.inner_html = , locals: { in_gallery: false } end end end. do || render(layout: , object: ) do ..map do || .node.inner_html = , locals: { in_gallery: true } .to_html end.join.html_safe end.chomp end end |
#render_action_text_content(content) ⇒ Object
12 13 14 15 |
# File 'app/helpers/action_text/content_helper.rb', line 12 def render_action_text_content(content) self.prefix_partial_path_with_controller_namespace = false sanitize_action_text_content((content)) end |
#sanitize_action_text_content(content) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'app/helpers/action_text/content_helper.rb', line 26 def sanitize_action_text_content(content) sanitizer.sanitize( content.to_html, tags: , attributes: sanitizer_allowed_attributes, scrubber: scrubber, ).html_safe end |
#sanitize_content_attachment(content_attachment) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'app/helpers/action_text/content_helper.rb', line 17 def () sanitizer.sanitize( , tags: , attributes: sanitizer_allowed_attributes, scrubber: scrubber, ) end |
#sanitizer_allowed_attributes ⇒ Object
70 71 72 |
# File 'app/helpers/action_text/content_helper.rb', line 70 def sanitizer_allowed_attributes allowed_attributes || (sanitizer.class.allowed_attributes + ActionText::Attachment::ATTRIBUTES) end |
#sanitizer_allowed_tags ⇒ Object
66 67 68 |
# File 'app/helpers/action_text/content_helper.rb', line 66 def || (sanitizer.class. + [ ActionText::Attachment.tag_name, "figure", "figcaption" ]) end |