bootstrap-email 1.0.0.alpha1 → 1.0.0.alpha3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/core/bootstrap-email.scss +2 -0
  4. data/core/bootstrap-head.scss +1 -1
  5. data/core/scss/_selectors_for_utils.scss +24 -0
  6. data/core/scss/_utilities.scss +24 -4
  7. data/core/scss/components/_grid.scss +12 -9
  8. data/core/scss/components/_stack.scss +33 -0
  9. data/core/scss/utilities/_sizing.scss +21 -2
  10. data/core/scss/utilities/_typography.scss +4 -10
  11. data/core/scss/utilities/_valign.scss +5 -0
  12. data/core/templates/body.html +9 -0
  13. data/core/templates/{container.html.erb → container.html} +4 -4
  14. data/core/templates/div.html +3 -0
  15. data/core/templates/table-left.html +9 -0
  16. data/core/templates/table-to-tbody.html +5 -0
  17. data/core/templates/table-to-tr.html +7 -0
  18. data/core/templates/table.html +9 -0
  19. data/core/templates/td.html +3 -0
  20. data/core/templates/tr.html +5 -0
  21. data/lib/{bootstrap_email.rb → bootstrap-email.rb} +6 -1
  22. data/lib/bootstrap-email/bootstrap_email_cli.rb +9 -9
  23. data/lib/bootstrap-email/compiler.rb +49 -65
  24. data/lib/bootstrap-email/config.rb +50 -0
  25. data/lib/bootstrap-email/{components → converters}/alert.rb +1 -1
  26. data/lib/bootstrap-email/converters/align.rb +22 -0
  27. data/lib/bootstrap-email/{components → converters}/badge.rb +1 -1
  28. data/lib/bootstrap-email/converters/base.rb +62 -0
  29. data/lib/bootstrap-email/converters/block.rb +13 -0
  30. data/lib/bootstrap-email/converters/body.rb +10 -0
  31. data/lib/bootstrap-email/{components → converters}/button.rb +1 -1
  32. data/lib/bootstrap-email/{components → converters}/card.rb +3 -3
  33. data/lib/bootstrap-email/{components → converters}/color.rb +1 -1
  34. data/lib/bootstrap-email/{components → converters}/container.rb +1 -1
  35. data/lib/bootstrap-email/converters/force_encoding.rb +16 -0
  36. data/lib/bootstrap-email/converters/grid.rb +14 -0
  37. data/lib/bootstrap-email/converters/head_style.rb +33 -0
  38. data/lib/bootstrap-email/{components → converters}/hr.rb +2 -2
  39. data/lib/bootstrap-email/{components → converters}/margin.rb +1 -1
  40. data/lib/bootstrap-email/{components → converters}/padding.rb +1 -1
  41. data/lib/bootstrap-email/converters/paragraph.rb +13 -0
  42. data/lib/bootstrap-email/converters/preview_text.rb +18 -0
  43. data/lib/bootstrap-email/{components → converters}/spacer.rb +1 -1
  44. data/lib/bootstrap-email/{components → converters}/spacing.rb +5 -6
  45. data/lib/bootstrap-email/converters/stack.rb +30 -0
  46. data/lib/bootstrap-email/{components → converters}/table.rb +1 -1
  47. data/lib/bootstrap-email/converters/version_comment.rb +15 -0
  48. data/lib/bootstrap-email/erb.rb +9 -0
  49. data/lib/bootstrap-email/rails/action_mailer.rb +7 -2
  50. data/lib/bootstrap-email/sass_cache.rb +43 -26
  51. data/lib/bootstrap-email/setup.rb +27 -0
  52. metadata +44 -31
  53. data/core/templates/body.html.erb +0 -9
  54. data/core/templates/col.html.erb +0 -3
  55. data/core/templates/div.html.erb +0 -3
  56. data/core/templates/row.html.erb +0 -7
  57. data/core/templates/table-left.html.erb +0 -9
  58. data/core/templates/table.html.erb +0 -9
  59. data/lib/bootstrap-email/components/align.rb +0 -21
  60. data/lib/bootstrap-email/components/base.rb +0 -26
  61. data/lib/bootstrap-email/components/body.rb +0 -22
  62. data/lib/bootstrap-email/components/grid.rb +0 -14
  63. data/lib/bootstrap-email/components/paragraph.rb +0 -24
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3a661e701ec3f8aa6589c588c9463a3a9fa4b74b1cddbc459632a7cf92a31259
4
- data.tar.gz: 5df12d3b814583187580a9b657384192c9f1fe5a16d338558691363cd0fb60a6
3
+ metadata.gz: f70b6dc2a2d0ebd4dfcdee53c7242e2aa6c7824571d41be81e0518e1516ce03c
4
+ data.tar.gz: c49e013fd55e2b2f87c204dc8b64ac093149e4d45df5e2d5da809540b2c4b399
5
5
  SHA512:
6
- metadata.gz: ba4287fac839103ebf7a3fa0a475037993c63c9fae9d28cc96e393e071dc5c8de59df0a147bf6ef0039ed42aa6c8a37fc96a1a019571af89d70abb90076e5c91
7
- data.tar.gz: 596260a7a2acbec5d44ad60b84e4f7c43d9fa47d940c48979670e4f1c70ff8c13c0ea0786bc2102c82d71a7f769128df9ba04b60a9686b35f7b53fc87d481030
6
+ metadata.gz: ab6c6bff12d2787b5962c51ae97983abdd407ccdd77e72a24e62644ff8e16d5a83d33e32ec14e577c9514731038091340c66ba47fd09c645380fc2aab27d42a6
7
+ data.tar.gz: 74a21957509ea73128b3d13c89dd21e0b6084c1a90efdac8ef4e3238e29e7ad4c10581d480665eacb578dd78c1177d9494e932bb20b841a93960cfb4b1497f8b
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0.alpha1
1
+ 1.0.0.alpha3
@@ -16,6 +16,7 @@
16
16
  @import 'scss/components/image';
17
17
  @import 'scss/components/preview';
18
18
  @import 'scss/components/table';
19
+ @import 'scss/components/stack';
19
20
 
20
21
  @import 'scss/utilities/background';
21
22
  @import 'scss/utilities/border';
@@ -26,3 +27,4 @@
26
27
  @import 'scss/utilities/spacing';
27
28
  @import 'scss/utilities/text-decoration';
28
29
  @import 'scss/utilities/typography';
30
+ @import 'scss/utilities/valign';
@@ -28,7 +28,7 @@ a {
28
28
  text-decoration: none;
29
29
  }
30
30
 
31
- // Inhere text color so color can be set on the body and inherited by children
31
+ // Inherit text color so color can be set on the body and inherited by children
32
32
  * {
33
33
  color: inherit;
34
34
  }
@@ -98,3 +98,27 @@
98
98
  }
99
99
  }
100
100
  }
101
+
102
+ //
103
+ // Text align
104
+ //
105
+ @mixin text-align-util($class) {
106
+ #{$class} {
107
+ &,
108
+ & > tbody > tr > td {
109
+ @content
110
+ }
111
+ }
112
+ }
113
+
114
+ //
115
+ // Vertical align
116
+ //
117
+ @mixin valign-util($class) {
118
+ #{$class} {
119
+ &,
120
+ & > tbody > tr > td {
121
+ @content
122
+ }
123
+ }
124
+ }
@@ -117,9 +117,29 @@ $border-widths: (
117
117
  ) !default;
118
118
 
119
119
  $border-radiuses: (
120
- '-sm': 3px,
121
- '': 6px,
122
- '-lg': 9px,
120
+ '': 4px,
121
+ '-none': 0px,
122
+ '-sm': 2px,
123
+ '-md': 6px,
124
+ '-lg': 8px,
123
125
  '-xl': 12px,
124
- '-0': 0px
126
+ '-2xl': 16px,
127
+ '-3xl': 24px,
128
+ '-full': 9999px
129
+ ) !default;
130
+
131
+ $vertical-align: (
132
+ top,
133
+ middle,
134
+ bottom,
135
+ baseline,
136
+ text-top,
137
+ text-bottom
138
+ ) !default;
139
+
140
+ $text-align: (
141
+ left,
142
+ right,
143
+ center,
144
+ justify
125
145
  ) !default;
@@ -1,10 +1,13 @@
1
1
  table.row {
2
2
  table-layout: fixed;
3
+ -premailer-width: 100%;
3
4
  width: 100%;
4
5
  & > tbody > tr > td {
5
6
  min-height: 1px;
6
7
  font-weight: normal;
7
- padding-right: 30px;
8
+ padding-right: 24px;
9
+ vertical-align: top;
10
+ text-align: left;
8
11
  }
9
12
  }
10
13
 
@@ -16,18 +19,18 @@ table.row {
16
19
  }
17
20
 
18
21
  @each $space, $value in $spacers {
19
- table.row.g-#{$space},
20
- table.row.gx-#{$space},
21
- table.row.g-lg-#{$space},
22
- table.row.gx-lg-#{$space} {
22
+ table.row.gap-#{$space},
23
+ table.row.gap-x-#{$space},
24
+ table.row.gap-lg-#{$space},
25
+ table.row.gap-x-lg-#{$space} {
23
26
  & > tbody > tr > td {
24
27
  padding-right: $value;
25
28
  }
26
29
  }
27
- table.row.g-#{$space},
28
- table.row.gy-#{$space},
29
- table.row.g-lg-#{$space},
30
- table.row.gy-lg-#{$space} {
30
+ table.row.gap-#{$space},
31
+ table.row.gap-y-#{$space},
32
+ table.row.gap-lg-#{$space},
33
+ table.row.gap-y-lg-#{$space} {
31
34
  & > tbody > tr > td {
32
35
  padding-bottom: $value;
33
36
  }
@@ -0,0 +1,33 @@
1
+ @each $space, $value in $spacers {
2
+ table.stack-x.gap-#{$space} > tbody > tr > td {
3
+ padding-right: $value;
4
+ &:last-child {
5
+ padding-right: 0;
6
+ }
7
+ }
8
+ table.stack-y.gap-#{$space} > tbody > tr {
9
+ & > td {
10
+ padding-bottom: $value;
11
+ }
12
+ &:last-child > td {
13
+ padding-bottom: 0;
14
+ }
15
+ }
16
+ }
17
+
18
+ .stack-cell {
19
+ vertical-align: top;
20
+ text-align: left;
21
+ }
22
+
23
+ @each $align in $vertical-align {
24
+ table.stack-valign-#{$align} > tbody > tr > td {
25
+ vertical-align: $align;
26
+ }
27
+ }
28
+
29
+ @each $align in $text-align {
30
+ table.stack-align-#{$align} > tbody > tr > td {
31
+ text-align: $align;
32
+ }
33
+ }
@@ -1,12 +1,12 @@
1
1
  @each $prefix in $breakpoints {
2
2
  @each $name, $property in $sizing-types {
3
- @include sizing-util('.#{$name}-#{$prefix}full') {
3
+ @include sizing-util('.max-#{$name}-#{$prefix}full') {
4
4
  max-#{$property}: 100%;
5
5
  -premailer-#{$property}: 100%;
6
6
  #{$property}: 100%;
7
7
  }
8
8
  @each $size, $value in $sizing {
9
- @include sizing-util('.#{$name}-#{$prefix}#{$size}') {
9
+ @include sizing-util('.max-#{$name}-#{$prefix}#{$size}') {
10
10
  max-#{$property}: $value;
11
11
  -premailer-#{$property}: strip-unit($value);
12
12
  #{$property}: 100%;
@@ -14,3 +14,22 @@
14
14
  }
15
15
  }
16
16
  }
17
+
18
+ @each $prefix in $breakpoints {
19
+ @each $name, $property in $sizing-types {
20
+ @include sizing-util('.#{$name}-#{$prefix}full') {
21
+ -premailer-#{$property}: 100%;
22
+ #{$property}: 100%;
23
+ }
24
+ @include sizing-util('.#{$name}-#{$prefix}auto') {
25
+ -premailer-#{$property}: auto;
26
+ #{$property}: auto;
27
+ }
28
+ @each $size, $value in $sizing {
29
+ @include sizing-util('.#{$name}-#{$prefix}#{$size}') {
30
+ -premailer-#{$property}: strip-unit($value);
31
+ #{$property}: $value;
32
+ }
33
+ }
34
+ }
35
+ }
@@ -36,16 +36,10 @@ h1, h2, h3, h4, h5, h6,
36
36
  }
37
37
  }
38
38
 
39
- .text-left {
40
- text-align: left !important;
41
- }
42
-
43
- .text-right {
44
- text-align: right !important;
45
- }
46
-
47
- .text-center {
48
- text-align: center !important;
39
+ @each $align in $text-align {
40
+ @include text-align-util('.text-#{$align}') {
41
+ text-align: $align !important;
42
+ }
49
43
  }
50
44
 
51
45
  p {
@@ -0,0 +1,5 @@
1
+ @each $align in $vertical-align {
2
+ @include valign-util('.valign-#{$align}') {
3
+ vertical-align: $align !important;
4
+ }
5
+ }
@@ -0,0 +1,9 @@
1
+ <table class="{{ classes }}" valign="top" role="presentation">
2
+ <tbody>
3
+ <tr>
4
+ <td valign="top">
5
+ {{ contents }}
6
+ </td>
7
+ </tr>
8
+ </tbody>
9
+ </table>
@@ -1,18 +1,18 @@
1
- <table class="<%= classes %>">
1
+ <table class="{{ classes }}" role="presentation">
2
2
  <tbody>
3
3
  <tr>
4
4
  <td align="center">
5
5
  <!--[if (gte mso 9)|(IE)]>
6
- <table align="center">
6
+ <table align="center" role="presentation">
7
7
  <tbody>
8
8
  <tr>
9
9
  <td width="600">
10
10
  <![endif]-->
11
- <table align="center">
11
+ <table align="center" role="presentation">
12
12
  <tbody>
13
13
  <tr>
14
14
  <td>
15
- <%= contents %>
15
+ {{ contents }}
16
16
  </td>
17
17
  </tr>
18
18
  </tbody>
@@ -0,0 +1,3 @@
1
+ <div class="{{ classes }}">
2
+ {{ contents }}
3
+ </div>
@@ -0,0 +1,9 @@
1
+ <table class="{{ classes }}" align="left" role="presentation">
2
+ <tbody>
3
+ <tr>
4
+ <td>
5
+ {{ contents }}
6
+ </td>
7
+ </tr>
8
+ </tbody>
9
+ </table>
@@ -0,0 +1,5 @@
1
+ <table class="{{ classes }}" role="presentation">
2
+ <tbody>
3
+ {{ contents }}
4
+ </tbody>
5
+ </table>
@@ -0,0 +1,7 @@
1
+ <table class="{{ classes }}" role="presentation">
2
+ <tbody>
3
+ <tr>
4
+ {{ contents }}
5
+ </tr>
6
+ </tbody>
7
+ </table>
@@ -0,0 +1,9 @@
1
+ <table class="{{ classes }}" role="presentation">
2
+ <tbody>
3
+ <tr>
4
+ <td>
5
+ {{ contents }}
6
+ </td>
7
+ </tr>
8
+ </tbody>
9
+ </table>
@@ -0,0 +1,3 @@
1
+ <td class="{{ classes }}">
2
+ {{ contents }}
3
+ </td>
@@ -0,0 +1,5 @@
1
+ <tr>
2
+ <td>
3
+ {{ contents }}
4
+ </td>
5
+ </tr>
@@ -5,6 +5,7 @@ require 'premailer'
5
5
  require 'sassc'
6
6
  require 'digest/sha1'
7
7
  require 'css_parser'
8
+ require 'fileutils'
8
9
 
9
10
  begin
10
11
  require 'rails'
@@ -15,10 +16,14 @@ if defined?(Rails)
15
16
  end
16
17
 
17
18
  require_relative 'bootstrap-email/initialize'
19
+ require_relative 'bootstrap-email/config'
20
+ require_relative 'bootstrap-email/setup'
21
+ require_relative 'bootstrap-email/erb'
18
22
  require_relative 'bootstrap-email/compiler'
19
23
  require_relative 'bootstrap-email/sass_cache'
20
24
  require_relative 'bootstrap-email/version'
21
- Dir[File.join(__dir__, 'bootstrap-email/components', '*.rb')].each { |file| require_relative file }
25
+ require_relative 'bootstrap-email/converters/base'
26
+ Dir[File.join(__dir__, 'bootstrap-email/converters', '*.rb')].each { |file| require_relative file }
22
27
 
23
28
  if defined?(Rails)
24
29
  require_relative 'bootstrap-email/rails/action_mailer'
@@ -1,10 +1,9 @@
1
- require_relative '../bootstrap_email'
1
+ require_relative '../bootstrap-email'
2
2
  require 'optparse'
3
- require 'fileutils'
4
3
 
5
4
  input = nil
6
5
  options = {
7
- destination: 'output',
6
+ destination: 'compiled',
8
7
  type: :file
9
8
  }
10
9
 
@@ -17,7 +16,7 @@ parser = OptionParser.new do |opts|
17
16
  opts.separator ' bootstrap-email email.html > out.html'
18
17
  opts.separator ' bootstrap-email ./public/index.html'
19
18
  opts.separator ' bootstrap-email -s \'<a href="#" class="btn btn-primary">Some Button</a>\''
20
- opts.separator ' bootstrap-email -p \'emails/*\' -d emails/output'
19
+ opts.separator ' bootstrap-email -p \'emails/*\' -d emails/compiled'
21
20
  opts.separator ' bootstrap-email -p \'views/emails/*\' -d \'views/compiled_emails\''
22
21
  opts.separator ' cat input.html | bootstrap-email'
23
22
  opts.separator ''
@@ -37,7 +36,7 @@ parser = OptionParser.new do |opts|
37
36
  options[:destination] = v
38
37
  end
39
38
 
40
- opts.on('-c', '--config STRING', String, 'Relative path to SCSS config config file to customize Bootstrap Email.') do |v|
39
+ opts.on('-c', '--config STRING', String, 'Relative path to ruby config file to customize Bootstrap Email.') do |v|
41
40
  options[:config] = File.expand_path(v, Dir.pwd)
42
41
  end
43
42
 
@@ -76,14 +75,15 @@ if input
76
75
 
77
76
  puts "Compiling file #{path}"
78
77
  compiled = BootstrapEmail::Compiler.new(path, type: :file, options: {config_path: options[:config]}).perform_full_compile
79
- FileUtils.mkdir_p("#{Dir.pwd}/#{options[:destination]}")
80
- File.write(File.expand_path("#{options[:destination]}/#{path.split('/').last}", Dir.pwd), compiled)
78
+ destination = options[:destination].chomp('/*')
79
+ FileUtils.mkdir_p("#{Dir.pwd}/#{destination}")
80
+ File.write(File.expand_path("#{destination}/#{path.split('/').last}", Dir.pwd), compiled)
81
81
  end
82
82
  when :file
83
83
  path = File.expand_path(input, Dir.pwd)
84
- puts BootstrapEmail::Compiler.new(File.join(Dir.pwd, path), type: :file, options: {config_path: options[:config]}).perform_full_compile
84
+ puts BootstrapEmail::Compiler.new(path, type: :file, options: {config_path: options[:config], sass_log_enabled: false}).perform_full_compile
85
85
  when :string
86
- puts BootstrapEmail::Compiler.new(input, options: {config_path: options[:config]}).perform_full_compile
86
+ puts BootstrapEmail::Compiler.new(input, options: {config_path: options[:config], sass_log_enabled: false}).perform_full_compile
87
87
  end
88
88
  else
89
89
  puts opts
@@ -3,6 +3,7 @@ module BootstrapEmail
3
3
  attr_accessor :type, :doc, :premailer
4
4
 
5
5
  def initialize(input, type: :string, options: {})
6
+ BootstrapEmail.load_options(options)
6
7
  self.type = type
7
8
  case type
8
9
  when :rails
@@ -13,23 +14,36 @@ module BootstrapEmail
13
14
  when :file
14
15
  html = File.read(input)
15
16
  end
16
- build_premailer_doc(html, options)
17
+ html = add_layout!(html)
18
+ sass_load_paths
19
+ build_premailer_doc(html)
17
20
  end
18
21
 
19
22
  def perform_full_compile
20
23
  compile_html!
21
24
  inline_css!
22
- inject_head!
23
- inject_comment!
25
+ configure_html!
24
26
  finalize_document!
25
27
  end
26
28
 
27
29
  private
28
30
 
29
- def build_premailer_doc(html, options)
30
- html = add_layout!(html)
31
- SassC.load_paths << File.expand_path('../../core', __dir__)
32
- css_string = BootstrapEmail::SassCache.compile('bootstrap-email', config_path: options[:config_path], style: :expanded)
31
+ def add_layout!(html)
32
+ document = Nokogiri::HTML(html)
33
+ return html unless document.at_css('head').nil?
34
+
35
+ BootstrapEmail::Erb.template(
36
+ File.expand_path('../../core/layout.html.erb', __dir__),
37
+ contents: html
38
+ )
39
+ end
40
+
41
+ def sass_load_paths
42
+ SassC.load_paths << BootstrapEmail.config.sass_load_paths
43
+ end
44
+
45
+ def build_premailer_doc(html)
46
+ css_string = BootstrapEmail::SassCache.compile('bootstrap-email', style: :expanded)
33
47
  self.premailer = Premailer.new(
34
48
  html,
35
49
  with_html_string: true,
@@ -39,80 +53,50 @@ module BootstrapEmail
39
53
  self.doc = premailer.doc
40
54
  end
41
55
 
42
- def add_layout!(html)
43
- document = Nokogiri::HTML(html)
44
- return document.to_html unless document.at_css('head').nil?
56
+ def compile_html!
57
+ BootstrapEmail::Converter::Block.build(doc)
45
58
 
46
- namespace = OpenStruct.new(contents: ERB.new(document.to_html).result)
47
- template_html = File.read(File.expand_path('../../core/layout.html.erb', __dir__))
48
- ERB.new(template_html).result(namespace.instance_eval { binding })
49
- end
59
+ BootstrapEmail::Converter::Button.build(doc)
60
+ BootstrapEmail::Converter::Badge.build(doc)
61
+ BootstrapEmail::Converter::Alert.build(doc)
62
+ BootstrapEmail::Converter::Card.build(doc)
63
+ BootstrapEmail::Converter::Hr.build(doc)
64
+ BootstrapEmail::Converter::Container.build(doc)
65
+ BootstrapEmail::Converter::Grid.build(doc)
66
+ BootstrapEmail::Converter::Stack.build(doc)
50
67
 
51
- def compile_html!
52
- BootstrapEmail::Component::Button.build(doc)
53
- BootstrapEmail::Component::Badge.build(doc)
54
- BootstrapEmail::Component::Alert.build(doc)
55
- BootstrapEmail::Component::Card.build(doc)
56
- BootstrapEmail::Component::Paragraph.build(doc)
57
- BootstrapEmail::Component::Hr.build(doc)
58
- BootstrapEmail::Component::Container.build(doc)
59
- BootstrapEmail::Component::Grid.build(doc)
60
- BootstrapEmail::Component::Align.build(doc)
61
- BootstrapEmail::Component::Color.build(doc)
62
- BootstrapEmail::Component::Padding.build(doc)
63
- BootstrapEmail::Component::Margin.build(doc)
64
- BootstrapEmail::Component::Spacing.build(doc)
65
- BootstrapEmail::Component::Spacer.build(doc)
66
- BootstrapEmail::Component::Table.build(doc)
67
- BootstrapEmail::Component::Body.build(doc)
68
+ BootstrapEmail::Converter::Spacing.build(doc)
69
+ BootstrapEmail::Converter::Padding.build(doc)
70
+ BootstrapEmail::Converter::Margin.build(doc)
71
+ BootstrapEmail::Converter::Spacer.build(doc)
72
+
73
+ BootstrapEmail::Converter::Table.build(doc)
74
+ BootstrapEmail::Converter::Body.build(doc)
75
+ BootstrapEmail::Converter::Align.build(doc)
76
+ BootstrapEmail::Converter::Color.build(doc)
77
+
78
+ BootstrapEmail::Converter::PreviewText.build(doc)
68
79
  end
69
80
 
70
81
  def inline_css!
71
82
  premailer.to_inline_css
72
83
  end
73
84
 
74
- def inject_head!
75
- doc.at_css('head').add_child(bootstrap_email_head)
76
- end
77
-
78
- def inject_comment!
79
- doc.at_css('head').prepend_child(bootstrap_email_comment)
85
+ def configure_html!
86
+ BootstrapEmail::Converter::ForceEncoding.build(doc)
87
+ BootstrapEmail::Converter::HeadStyle.build(doc)
88
+ BootstrapEmail::Converter::VersionComment.build(doc)
80
89
  end
81
90
 
82
91
  def finalize_document!
92
+ html = BootstrapEmail::Converter::ForceEncoding.replace(doc.to_html)
83
93
  case type
84
94
  when :rails
85
- (@mail.html_part || @mail).body = doc.to_html
95
+ (@mail.html_part || @mail).body = html
86
96
  @mail
87
97
  when :string, :file
88
- doc.to_html
89
- end
90
- end
91
-
92
- def bootstrap_email_head
93
- html_string = <<-INLINE
94
- <style type="text/css">
95
- #{purged_css_from_head}
96
- </style>
97
- INLINE
98
- html_string
99
- end
100
-
101
- def bootstrap_email_comment
102
- "\n <!-- Compiled with Bootstrap Email version: #{BootstrapEmail::VERSION} -->"
103
- end
104
-
105
- def purged_css_from_head
106
- default, custom = BootstrapEmail::SassCache.compile('bootstrap-head').split('/*! allow_purge_after */')
107
- # get each CSS declaration
108
- custom.scan(/\w*\.[\w\-]*[\s\S\n]+?(?=})}{1}/).each do |group|
109
- # get the first class for each comma separated CSS declaration
110
- exist = group.scan(/(\.[\w\-]*).*?((,+?)|{+?)/).map(&:first).uniq.any? do |selector|
111
- !doc.at_css(selector).nil?
112
- end
113
- custom.sub!(group, '') unless exist
98
+ html
114
99
  end
115
- (default + custom).gsub(/\n\s*\n+/, "\n")
116
100
  end
117
101
  end
118
102
  end