Module: Thredded::EmailTransformer::Helpers
- Included in:
- Base
- Defined in:
- lib/thredded/email_transformer/base.rb
Overview
A helper module with common functions for constructing Nokogiri elements.
Instance Method Summary collapse
-
#anchor(href, target: '_blank', content: href) ⇒ Object
Creates an ‘<a>` node with the given attributes and content.
-
#paragraph(child) ⇒ Object
Creates a ‘<p>` node with the given child.
Instance Method Details
#anchor(href, target: '_blank', content: href) ⇒ Object
Creates an ‘<a>` node with the given attributes and content
15 16 17 18 19 20 21 |
# File 'lib/thredded/email_transformer/base.rb', line 15 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 |
#paragraph(child) ⇒ Object
Creates a ‘<p>` node with the given child
8 9 10 11 12 |
# File 'lib/thredded/email_transformer/base.rb', line 8 def paragraph(child) Nokogiri::XML::Node.new('p', doc).tap do |p| p.add_child child end end |