Sha256: 11a91cac6b3b33626bcc5f1544690945cf652ce29072f63314a39c61e4a52d55
Contents?: true
Size: 844 Bytes
Versions: 24
Compression:
Stored size: 844 Bytes
Contents
# frozen_string_literal: true require 'thredded/email_transformer/base' module Thredded module EmailTransformer # Changes the spoiler tags to work in emails. class Spoiler < Base def call doc.css('.thredded--post--content--spoiler--summary').each do |node| node.content = I18n.t('thredded.posts.spoiler_summary_for_email') end doc.css('.thredded--post--content--spoiler--contents img').each do |img| text = "#{img['src']} #{" (#{img['alt']})" if img['alt'].present?}" img.swap( if img.parent.name == 'a' && img.parent.children.size == 1 doc.document.create_text_node(text) else doc.document.create_element('a', text, href: img['src'], target: '_blank') end ) end end end end end
Version data entries
24 entries across 24 versions & 1 rubygems