Class: BootstrapEmail::Compiler

Inherits:
Object
  • Object
show all
Defined in:
lib/bootstrap-email/compiler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input, type: :string, options: {}) ⇒ Compiler

Returns a new instance of Compiler.



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/bootstrap-email/compiler.rb', line 7

def initialize(input, type: :string, options: {})
  self.config = BootstrapEmail::Config.new(options)
  self.type = type
  case type
  when :string
    html = input
  when :file
    html = File.read(input)
  end
  html = add_layout(html)
  sass_load_paths
  build_premailer_doc(html)
end

Instance Attribute Details

#configObject

Returns the value of attribute config.



5
6
7
# File 'lib/bootstrap-email/compiler.rb', line 5

def config
  @config
end

#docObject

Returns the value of attribute doc.



5
6
7
# File 'lib/bootstrap-email/compiler.rb', line 5

def doc
  @doc
end

#premailerObject

Returns the value of attribute premailer.



5
6
7
# File 'lib/bootstrap-email/compiler.rb', line 5

def premailer
  @premailer
end

#typeObject

Returns the value of attribute type.



5
6
7
# File 'lib/bootstrap-email/compiler.rb', line 5

def type
  @type
end

Instance Method Details

#perform_html_compileObject Also known as: perform_full_compile



32
33
34
35
36
37
38
39
# File 'lib/bootstrap-email/compiler.rb', line 32

def perform_html_compile
  @perform_html_compile ||= begin
    compile_html
    inline_css
    configure_html
    finalize_document
  end
end

#perform_multipart_compileObject



21
22
23
24
25
26
# File 'lib/bootstrap-email/compiler.rb', line 21

def perform_multipart_compile
  @perform_multipart_compile ||= {
    text: perform_text_compile,
    html: perform_html_compile
  }
end

#perform_text_compileObject



28
29
30
# File 'lib/bootstrap-email/compiler.rb', line 28

def perform_text_compile
  @perform_text_compile ||= plain_text
end