Class: AwesomeMailer::Renderer
- Inherits:
-
Object
- Object
- AwesomeMailer::Renderer
- Defined in:
- lib/awesome_mailer/renderer.rb
Instance Attribute Summary collapse
-
#document ⇒ Object
Returns the value of attribute document.
Instance Method Summary collapse
-
#initialize(document_string) ⇒ Renderer
constructor
A new instance of Renderer.
- #to_html ⇒ Object
Constructor Details
#initialize(document_string) ⇒ Renderer
Returns a new instance of Renderer.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/awesome_mailer/renderer.rb', line 8 def initialize(document_string) self.document = Nokogiri::HTML.parse(document_string) stylesheets = document.search('link[@rel=stylesheet]') stylesheets.each do |stylesheet| # Must be intended for digital screens! load_stylesheet(stylesheet) if stylesheet['media'] =~ /^(all|handheld|screen)$/ end inline_stylesheets = document.search('style') inline_stylesheets.each do |styles| css_parser.add_block!(styles.inner_html) styles.remove end apply_css! end |
Instance Attribute Details
#document ⇒ Object
Returns the value of attribute document.
6 7 8 |
# File 'lib/awesome_mailer/renderer.rb', line 6 def document @document end |
Instance Method Details
#to_html ⇒ Object
23 24 25 |
# File 'lib/awesome_mailer/renderer.rb', line 23 def to_html document.to_html end |