Class: BootstrapEmail::Converter::PreviewText

Inherits:
Base
  • Object
show all
Defined in:
lib/bootstrap-email/converters/preview_text.rb

Instance Attribute Summary

Attributes inherited from Base

#doc

Instance Method Summary collapse

Methods inherited from Base

build, #initialize

Constructor Details

This class inherits a constructor from BootstrapEmail::Converter::Base

Instance Method Details

#buildObject



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/bootstrap-email/converters/preview_text.rb', line 4

def build
  preview_node = doc.at_css('preview')
  return if preview_node.nil?

  # apply spacing after the text max of 100 characters so it doesn't show body text
  preview_node.inner_html += ' ' * [(100 - preview_node.content.length.to_i), 0].max
  node = template('div', classes: 'preview', contents: preview_node.content)
  preview_node.remove

  body = doc.at_css('body')
  body.prepend_child(node)
end