Class: BootstrapEmail::Compiler
- Inherits:
-
Object
- Object
- BootstrapEmail::Compiler
- Defined in:
- lib/bootstrap-email.rb
Instance Method Summary collapse
- #compile_html! ⇒ Object
-
#initialize(mail) ⇒ Compiler
constructor
A new instance of Compiler.
- #inject_head! ⇒ Object
- #inline_css! ⇒ Object
- #perform_full_compile ⇒ Object
- #update_doc(source) ⇒ Object
- #update_mailer! ⇒ Object
Constructor Details
#initialize(mail) ⇒ Compiler
Returns a new instance of Compiler.
11 12 13 14 15 |
# File 'lib/bootstrap-email.rb', line 11 def initialize mail @mail = mail @source = mail.html_part || mail update_doc(@source.body.raw_source) end |
Instance Method Details
#compile_html! ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/bootstrap-email.rb', line 28 def compile_html! badge alert card hr container grid align padding margin spacer table body end |
#inject_head! ⇒ Object
51 52 53 |
# File 'lib/bootstrap-email.rb', line 51 def inject_head! @doc.at_css('head').add_child(bootstrap_email_head) end |
#inline_css! ⇒ Object
44 45 46 47 48 49 |
# File 'lib/bootstrap-email.rb', line 44 def inline_css! @source.body = @doc.to_html @mail = Premailer::Rails::Hook.perform(@mail) @mail.header[:skip_premailer] = true update_doc(@mail.html_part.body.raw_source) end |
#perform_full_compile ⇒ Object
21 22 23 24 25 26 |
# File 'lib/bootstrap-email.rb', line 21 def perform_full_compile compile_html! inline_css! inject_head! update_mailer! end |
#update_doc(source) ⇒ Object
17 18 19 |
# File 'lib/bootstrap-email.rb', line 17 def update_doc source @doc = Nokogiri::HTML(source) end |
#update_mailer! ⇒ Object
55 56 57 58 |
# File 'lib/bootstrap-email.rb', line 55 def update_mailer! @mail.html_part.body = @doc.to_html @mail end |