Sha256: 8e00330da02a6b3fd25ccc6c215de88e127e0080bb634674f1f3f607f7e4af45
Contents?: true
Size: 1.07 KB
Versions: 46
Compression:
Stored size: 1.07 KB
Contents
# frozen_string_literal: true module Thredded module EmailTransformer # A helper module with common functions for constructing Nokogiri elements. module Helpers # Creates a `<p>` node with the given child def paragraph(child) Nokogiri::XML::Node.new('p', doc).tap do |p| p.add_child child end end # Creates an `<a>` node with the given attributes and content def anchor(href, target: '_blank', content: href) Nokogiri::XML::Node.new('a', doc).tap do |a| a['href'] = href a['target'] = target a.content = content end end end class Base include Helpers # @return [Nokogiri::HTML::Document] attr_reader :doc # @param doc [Nokogiri::HTML::Document] def initialize(doc) @doc = doc end def self.inherited(base) base.extend ClassMethods end module ClassMethods # @param doc [Nokogiri::HTML::Document] def call(doc) new(doc).call end end end end end
Version data entries
46 entries across 46 versions & 2 rubygems