bootstrap-email 0.3.4 → 1.0.0.alpha2.1
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.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/bin/bootstrap-email +2 -0
- data/core/bootstrap-email.scss +29 -18
- data/core/bootstrap-head.scss +143 -0
- data/core/layout.html.erb +11 -0
- data/core/scss/_colors.scss +161 -0
- data/core/scss/_functions.scss +29 -0
- data/core/scss/_helper_groups.scss +21 -0
- data/core/{sass → scss}/_reboot_email.scss +7 -22
- data/core/scss/_selectors_for_utils.scss +124 -0
- data/core/scss/_utilities.scss +145 -0
- data/core/scss/_variables.scss +52 -0
- data/core/{sass → scss/components}/_alert.scss +0 -1
- data/core/{sass → scss/components}/_badge.scss +8 -15
- data/core/{sass → scss/components}/_button.scss +21 -17
- data/core/{sass → scss/components}/_card.scss +3 -2
- data/core/{sass → scss/components}/_container.scss +0 -0
- data/core/scss/components/_grid.scss +38 -0
- data/core/scss/components/_hr.scss +8 -0
- data/core/{sass → scss/components}/_image.scss +2 -1
- data/core/{sass → scss/components}/_preview.scss +0 -0
- data/core/scss/components/_stack.scss +33 -0
- data/core/{sass → scss/components}/_table.scss +0 -0
- data/core/scss/utilities/_background.scss +5 -0
- data/core/scss/utilities/_border-radius.scss +21 -0
- data/core/scss/utilities/_border.scss +13 -0
- data/core/scss/utilities/_color.scss +9 -0
- data/core/scss/utilities/_display.scss +7 -0
- data/core/scss/utilities/_sizing.scss +31 -0
- data/core/scss/utilities/_spacing.scss +18 -0
- data/core/scss/utilities/_text-decoration.scss +9 -0
- data/core/scss/utilities/_typography.scss +48 -0
- data/core/scss/utilities/_valign.scss +5 -0
- data/core/templates/body.html.erb +1 -1
- data/core/templates/container.html.erb +3 -3
- data/core/templates/table-left.html.erb +1 -1
- data/core/templates/table-to-tbody.html.erb +5 -0
- data/core/templates/table-to-tr.html.erb +7 -0
- data/core/templates/table.html.erb +1 -1
- data/core/templates/td.html.erb +3 -0
- data/core/templates/tr.html.erb +5 -0
- data/lib/bootstrap-email.rb +20 -222
- data/lib/bootstrap-email/bootstrap_email_cli.rb +92 -0
- data/lib/bootstrap-email/compiler.rb +98 -0
- data/lib/bootstrap-email/components/alert.rb +11 -0
- data/lib/bootstrap-email/components/align.rb +22 -0
- data/lib/bootstrap-email/components/badge.rb +11 -0
- data/lib/bootstrap-email/components/base.rb +54 -0
- data/lib/bootstrap-email/components/block.rb +13 -0
- data/lib/bootstrap-email/components/body.rb +10 -0
- data/lib/bootstrap-email/components/button.rb +11 -0
- data/lib/bootstrap-email/components/card.rb +14 -0
- data/lib/bootstrap-email/components/color.rb +13 -0
- data/lib/bootstrap-email/components/container.rb +14 -0
- data/lib/bootstrap-email/components/force_encoding.rb +16 -0
- data/lib/bootstrap-email/components/grid.rb +14 -0
- data/lib/bootstrap-email/components/head_style.rb +33 -0
- data/lib/bootstrap-email/components/hr.rb +12 -0
- data/lib/bootstrap-email/components/margin.rb +22 -0
- data/lib/bootstrap-email/components/padding.rb +16 -0
- data/lib/bootstrap-email/components/paragraph.rb +13 -0
- data/lib/bootstrap-email/components/preview_text.rb +18 -0
- data/lib/bootstrap-email/components/spacer.rb +11 -0
- data/lib/bootstrap-email/components/spacing.rb +17 -0
- data/lib/bootstrap-email/components/stack.rb +30 -0
- data/lib/bootstrap-email/components/table.rb +13 -0
- data/lib/bootstrap-email/components/version_comment.rb +15 -0
- data/lib/bootstrap-email/erb.rb +9 -0
- data/lib/bootstrap-email/initialize.rb +1 -0
- data/lib/bootstrap-email/rails/action_mailer.rb +15 -0
- data/lib/bootstrap-email/{engine.rb → rails/engine.rb} +0 -0
- data/lib/bootstrap-email/sass_cache.rb +67 -0
- data/lib/bootstrap-email/version.rb +3 -5
- metadata +82 -59
- data/core/head.scss +0 -269
- data/core/sass/_border.scss +0 -73
- data/core/sass/_color.scss +0 -33
- data/core/sass/_display.scss +0 -7
- data/core/sass/_functions.scss +0 -14
- data/core/sass/_grid.scss +0 -131
- data/core/sass/_hr.scss +0 -13
- data/core/sass/_spacing.scss +0 -100
- data/core/sass/_typography.scss +0 -50
- data/core/sass/_variables.scss +0 -150
- data/core/template.html.erb +0 -11
- data/core/templates/align-center.html.erb +0 -9
- data/core/templates/align-left.html.erb +0 -9
- data/core/templates/align-right.html.erb +0 -9
- data/core/templates/col.html.erb +0 -3
- data/core/templates/hr.html.erb +0 -9
- data/core/templates/row.html.erb +0 -7
- data/lib/assets/stylesheets/bootstrap-email.scss +0 -1
- data/lib/bootstrap-email/action_mailer.rb +0 -14
- data/lib/bootstrap-email/premailer_railtie.rb +0 -5
File without changes
|
@@ -0,0 +1,38 @@
|
|
1
|
+
table.row {
|
2
|
+
table-layout: fixed;
|
3
|
+
-premailer-width: 100%;
|
4
|
+
width: 100%;
|
5
|
+
& > tbody > tr > td {
|
6
|
+
min-height: 1px;
|
7
|
+
font-weight: normal;
|
8
|
+
padding-right: 30px;
|
9
|
+
vertical-align: top;
|
10
|
+
text-align: left;
|
11
|
+
}
|
12
|
+
}
|
13
|
+
|
14
|
+
@each $key, $value in $grid-cols {
|
15
|
+
td.col-#{$key},
|
16
|
+
td.col-lg-#{$key} {
|
17
|
+
width: $value;
|
18
|
+
}
|
19
|
+
}
|
20
|
+
|
21
|
+
@each $space, $value in $spacers {
|
22
|
+
table.row.g-#{$space},
|
23
|
+
table.row.gx-#{$space},
|
24
|
+
table.row.g-lg-#{$space},
|
25
|
+
table.row.gx-lg-#{$space} {
|
26
|
+
& > tbody > tr > td {
|
27
|
+
padding-right: $value;
|
28
|
+
}
|
29
|
+
}
|
30
|
+
table.row.g-#{$space},
|
31
|
+
table.row.gy-#{$space},
|
32
|
+
table.row.g-lg-#{$space},
|
33
|
+
table.row.gy-lg-#{$space} {
|
34
|
+
& > tbody > tr > td {
|
35
|
+
padding-bottom: $value;
|
36
|
+
}
|
37
|
+
}
|
38
|
+
}
|
File without changes
|
@@ -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
|
+
}
|
File without changes
|
@@ -0,0 +1,21 @@
|
|
1
|
+
@each $name, $radius in $border-radiuses {
|
2
|
+
@include border-radius-util('.rounded#{$name}') {
|
3
|
+
border-radius: $radius;
|
4
|
+
}
|
5
|
+
@include border-radius-util('.rounded-top#{$name}') {
|
6
|
+
border-top-left-radius: $radius;
|
7
|
+
border-top-right-radius: $radius;
|
8
|
+
}
|
9
|
+
@include border-radius-util('.rounded-right#{$name}') {
|
10
|
+
border-top-right-radius: $radius;
|
11
|
+
border-bottom-right-radius: $radius;
|
12
|
+
}
|
13
|
+
@include border-radius-util('.rounded-bottom#{$name}') {
|
14
|
+
border-bottom-right-radius: $radius;
|
15
|
+
border-bottom-left-radius: $radius;
|
16
|
+
}
|
17
|
+
@include border-radius-util('.rounded-left#{$name}') {
|
18
|
+
border-top-left-radius: $radius;
|
19
|
+
border-bottom-left-radius: $radius;
|
20
|
+
}
|
21
|
+
}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
@each $name, $width in $border-widths {
|
2
|
+
.border#{$name} { border: $width solid $border-color !important; }
|
3
|
+
.border-top#{$name} { border-top: $width solid $border-color !important; }
|
4
|
+
.border-right#{$name} { border-right: $width solid $border-color !important; }
|
5
|
+
.border-bottom#{$name} { border-bottom: $width solid $border-color !important; }
|
6
|
+
.border-left#{$name} { border-left: $width solid $border-color !important; }
|
7
|
+
}
|
8
|
+
|
9
|
+
@each $name, $color in $all-colors {
|
10
|
+
@include border-color-util('.border-#{$name}') {
|
11
|
+
border-color: $color !important;
|
12
|
+
}
|
13
|
+
}
|
@@ -0,0 +1,31 @@
|
|
1
|
+
@each $prefix in $breakpoints {
|
2
|
+
@each $name, $property in $sizing-types {
|
3
|
+
@include sizing-util('.max-#{$name}-#{$prefix}full') {
|
4
|
+
max-#{$property}: 100%;
|
5
|
+
-premailer-#{$property}: 100%;
|
6
|
+
#{$property}: 100%;
|
7
|
+
}
|
8
|
+
@each $size, $value in $sizing {
|
9
|
+
@include sizing-util('.max-#{$name}-#{$prefix}#{$size}') {
|
10
|
+
max-#{$property}: $value;
|
11
|
+
-premailer-#{$property}: strip-unit($value);
|
12
|
+
#{$property}: 100%;
|
13
|
+
}
|
14
|
+
}
|
15
|
+
}
|
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
|
+
@each $size, $value in $sizing {
|
25
|
+
@include sizing-util('.#{$name}-#{$prefix}#{$size}') {
|
26
|
+
-premailer-#{$property}: strip-unit($value);
|
27
|
+
#{$property}: $value;
|
28
|
+
}
|
29
|
+
}
|
30
|
+
}
|
31
|
+
}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
// Padding Util
|
2
|
+
@each $prefix in $breakpoints {
|
3
|
+
@each $size, $value in $spacers {
|
4
|
+
@include padding-group($prefix, $size, $value);
|
5
|
+
}
|
6
|
+
}
|
7
|
+
|
8
|
+
// Spacing Util
|
9
|
+
@each $prefix in $breakpoints {
|
10
|
+
@each $size, $value in $spacers {
|
11
|
+
@include spacer-util('.s-#{$prefix}#{$size}') {
|
12
|
+
font-size: $value;
|
13
|
+
line-height: $value;
|
14
|
+
height: $value;
|
15
|
+
-premailer-height: strip-unit($value);
|
16
|
+
}
|
17
|
+
}
|
18
|
+
}
|
@@ -0,0 +1,48 @@
|
|
1
|
+
h1, h2, h3, h4, h5, h6,
|
2
|
+
.h1, .h2, .h3, .h4, .h5, .h6 {
|
3
|
+
margin: 0;
|
4
|
+
padding-top: $headings-margin-top;
|
5
|
+
padding-bottom: $headings-margin-bottom;
|
6
|
+
font-family: $headings-font-family;
|
7
|
+
font-weight: $headings-font-weight;
|
8
|
+
color: $headings-color;
|
9
|
+
text-align: left;
|
10
|
+
vertical-align: baseline;
|
11
|
+
}
|
12
|
+
|
13
|
+
@each $name, $size in $headings {
|
14
|
+
h#{$name}, .h#{$name} {
|
15
|
+
font-size: $size;
|
16
|
+
line-height: $size * $headings-line-height;
|
17
|
+
}
|
18
|
+
}
|
19
|
+
|
20
|
+
@each $name, $size in $font-size {
|
21
|
+
.text-#{$name} {
|
22
|
+
font-size: $size;
|
23
|
+
line-height: $size * $headings-line-height;
|
24
|
+
}
|
25
|
+
}
|
26
|
+
|
27
|
+
@each $name, $size in $line-height {
|
28
|
+
.lh-#{$name} {
|
29
|
+
line-height: $size;
|
30
|
+
}
|
31
|
+
}
|
32
|
+
|
33
|
+
@for $n from 1 through 9 {
|
34
|
+
@include font-weight-util('.fw-#{$n * 100}') {
|
35
|
+
font-weight: #{$n * 100} !important;
|
36
|
+
}
|
37
|
+
}
|
38
|
+
|
39
|
+
@each $align in $text-align {
|
40
|
+
@include text-align-util('.text-#{$align}') {
|
41
|
+
text-align: $align !important;
|
42
|
+
}
|
43
|
+
}
|
44
|
+
|
45
|
+
p {
|
46
|
+
width: 100%;
|
47
|
+
margin: 0;
|
48
|
+
}
|
@@ -1,14 +1,14 @@
|
|
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>
|
data/lib/bootstrap-email.rb
CHANGED
@@ -1,230 +1,28 @@
|
|
1
1
|
require 'nokogiri'
|
2
2
|
require 'erb'
|
3
3
|
require 'ostruct'
|
4
|
-
require 'action_mailer'
|
5
4
|
require 'premailer'
|
6
|
-
require '
|
7
|
-
require '
|
5
|
+
require 'sassc'
|
6
|
+
require 'digest/sha1'
|
7
|
+
require 'css_parser'
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
@mail = mail
|
13
|
-
@source = mail.html_part || mail
|
14
|
-
update_doc(@source.body.raw_source)
|
15
|
-
end
|
9
|
+
begin
|
10
|
+
require 'rails'
|
11
|
+
rescue LoadError; end
|
16
12
|
|
17
|
-
|
18
|
-
|
19
|
-
end
|
20
|
-
|
21
|
-
def perform_full_compile
|
22
|
-
compile_html!
|
23
|
-
inline_css!
|
24
|
-
inject_head!
|
25
|
-
update_mailer!
|
26
|
-
end
|
27
|
-
|
28
|
-
def compile_html!
|
29
|
-
button
|
30
|
-
badge
|
31
|
-
alert
|
32
|
-
card
|
33
|
-
hr
|
34
|
-
container
|
35
|
-
grid
|
36
|
-
align
|
37
|
-
padding
|
38
|
-
margin
|
39
|
-
spacer
|
40
|
-
table
|
41
|
-
body
|
42
|
-
end
|
43
|
-
|
44
|
-
def inline_css!
|
45
|
-
@source.body = @doc.to_html
|
46
|
-
@mail = Premailer::Rails::Hook.perform(@mail)
|
47
|
-
@mail.header[:skip_premailer] = true
|
48
|
-
update_doc(@mail.html_part.body.raw_source)
|
49
|
-
end
|
50
|
-
|
51
|
-
def inject_head!
|
52
|
-
@doc.at_css('head').add_child(bootstrap_email_head)
|
53
|
-
end
|
54
|
-
|
55
|
-
def update_mailer!
|
56
|
-
@mail.html_part.body = @doc.to_html
|
57
|
-
@mail
|
58
|
-
end
|
59
|
-
|
60
|
-
private
|
61
|
-
|
62
|
-
def bootstrap_email_head
|
63
|
-
engine = defined?(SassC::Engine).nil? ? Sass::Engine : SassC::Engine
|
64
|
-
html_string = <<-HEREDOC
|
65
|
-
<style type="text/css">
|
66
|
-
#{engine.new(File.open(File.expand_path('../core/head.scss', __dir__)).read, syntax: :scss, style: :compressed, cache: false, read_cache: false).render}
|
67
|
-
</style>
|
68
|
-
HEREDOC
|
69
|
-
html_string
|
70
|
-
end
|
71
|
-
|
72
|
-
def template(file, locals_hash = {})
|
73
|
-
namespace = OpenStruct.new(locals_hash)
|
74
|
-
template_html = File.open(File.expand_path("../core/templates/#{file}.html.erb", __dir__)).read
|
75
|
-
ERB.new(template_html).result(namespace.instance_eval { binding })
|
76
|
-
end
|
77
|
-
|
78
|
-
def each_node(css_lookup, &blk)
|
79
|
-
# sort by youngest child and traverse backwards up the tree
|
80
|
-
@doc.css(css_lookup).sort_by { |n| n.ancestors.size }.reverse!.each(&blk)
|
81
|
-
end
|
82
|
-
|
83
|
-
def button
|
84
|
-
each_node('.btn') do |node| # move all classes up and remove all classes from the element
|
85
|
-
node.replace(template('table', classes: node['class'], contents: node.delete('class') && node.to_html))
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
def badge
|
90
|
-
each_node('.badge') do |node| # move all classes up and remove all classes from the element
|
91
|
-
node.replace(template('table-left', classes: node['class'], contents: node.delete('class') && node.to_html))
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
def alert
|
96
|
-
each_node('.alert') do |node| # move all classes up and remove all classes from the element
|
97
|
-
node.replace(template('table', classes: node['class'], contents: node.delete('class') && node.to_html))
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
def align
|
102
|
-
each_node('.float-left') do |node|
|
103
|
-
align_helper(node, /float-left/, 'left')
|
104
|
-
end
|
105
|
-
each_node('.mx-auto') do |node|
|
106
|
-
align_helper(node, /mx-auto/, 'center')
|
107
|
-
end
|
108
|
-
each_node('.float-right') do |node|
|
109
|
-
align_helper(node, /float-right/, 'right')
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
|
-
def align_helper(node, klass, template)
|
114
|
-
if node.name != 'table' # if it is already on a table, set the proprieties on the current table
|
115
|
-
node['class'] = node['class'].sub(klass, '')
|
116
|
-
node.replace(template("align-#{template}", contents: node.to_html))
|
117
|
-
else
|
118
|
-
node['align'] = template
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
def card
|
123
|
-
each_node('.card') do |node| # move all classes up and remove all classes from element
|
124
|
-
node.replace(template('table', classes: node['class'], contents: node.delete('class') && node.to_html))
|
125
|
-
end
|
126
|
-
each_node('.card-body') do |node| # move all classes up and remove all classes from element
|
127
|
-
node.replace(template('table', classes: node['class'], contents: node.delete('class') && node.to_html))
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
def hr
|
132
|
-
each_node('hr') do |node| # drop hr in place of current
|
133
|
-
node.replace(template('hr', classes: "hr #{node['class']}"))
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
def container
|
138
|
-
each_node('.container') do |node|
|
139
|
-
node.replace(template('container', classes: node['class'], contents: node.inner_html))
|
140
|
-
end
|
141
|
-
each_node('.container-fluid') do |node|
|
142
|
-
node.replace(template('table', classes: node['class'], contents: node.inner_html))
|
143
|
-
end
|
144
|
-
end
|
145
|
-
|
146
|
-
def grid
|
147
|
-
each_node('.row') do |node|
|
148
|
-
node.replace(template('row', classes: node['class'], contents: node.inner_html))
|
149
|
-
end
|
150
|
-
each_node('*[class*=col]') do |node|
|
151
|
-
node.replace(template('col', classes: node['class'], contents: node.inner_html))
|
152
|
-
end
|
153
|
-
end
|
154
|
-
|
155
|
-
def padding
|
156
|
-
each_node('*[class*=p-], *[class*=pt-], *[class*=pr-], *[class*=pb-], *[class*=pl-], *[class*=px-], *[class*=py-]') do |node|
|
157
|
-
next unless node.name != 'table' # if it is already on a table, set the padding on the table, else wrap the content in a table
|
158
|
-
|
159
|
-
padding_regex = /(p[trblxy]?-\d)/
|
160
|
-
classes = node['class'].scan(padding_regex).join(' ')
|
161
|
-
node['class'] = node['class'].gsub(padding_regex, '')
|
162
|
-
node.replace(template('table', classes: classes, contents: node.to_html))
|
163
|
-
end
|
164
|
-
end
|
165
|
-
|
166
|
-
def margin
|
167
|
-
each_node('*[class*=my-], *[class*=mt-], *[class*=mb-]') do |node|
|
168
|
-
top_class = node['class'][/m[ty]{1}-(lg-)?(\d)/]
|
169
|
-
bottom_class = node['class'][/m[by]{1}-(lg-)?(\d)/]
|
170
|
-
node['class'] = node['class'].gsub(/(m[tby]{1}-(lg-)?\d)/, '')
|
171
|
-
html = ''
|
172
|
-
if top_class
|
173
|
-
html += template('div', classes: "s-#{top_class.gsub(/m[ty]{1}-/, '')}", contents: nil)
|
174
|
-
end
|
175
|
-
html += node.to_html
|
176
|
-
if bottom_class
|
177
|
-
html += template('div', classes: "s-#{bottom_class.gsub(/m[by]{1}-/, '')}", contents: nil)
|
178
|
-
end
|
179
|
-
node.replace(html)
|
180
|
-
end
|
181
|
-
end
|
182
|
-
|
183
|
-
def spacer
|
184
|
-
spacers = {
|
185
|
-
'0' => 0,
|
186
|
-
'1' => (16 * 0.25),
|
187
|
-
'2' => (16 * 0.5),
|
188
|
-
'3' => 16,
|
189
|
-
'4' => (16 * 1.5),
|
190
|
-
'5' => (16 * 3)
|
191
|
-
}
|
192
|
-
each_node('*[class*=s-]') do |node|
|
193
|
-
temp = Nokogiri::HTML::DocumentFragment.parse(template('table', classes: node['class'] + ' w-100', contents: ' '))
|
194
|
-
temp.at_css('td')['height'] = spacers[node['class'].gsub(/s-/, '')].to_i
|
195
|
-
node.replace(temp)
|
196
|
-
end
|
197
|
-
end
|
198
|
-
|
199
|
-
def table
|
200
|
-
@doc.css('table').each do |node|
|
201
|
-
# border="0" cellpadding="0" cellspacing="0"
|
202
|
-
node['border'] = 0
|
203
|
-
node['cellpadding'] = 0
|
204
|
-
node['cellspacing'] = 0
|
205
|
-
end
|
206
|
-
end
|
207
|
-
|
208
|
-
def body
|
209
|
-
@doc.css('body').each do |node|
|
210
|
-
node.replace('<body>' + preview_text.to_s + template('body', classes: "#{node['class']} body", contents: node.inner_html.to_s) + '</body>')
|
211
|
-
end
|
212
|
-
end
|
213
|
-
|
214
|
-
def preview_text
|
215
|
-
preview_node = @doc.at_css('preview')
|
216
|
-
return if preview_node.blank?
|
217
|
-
|
218
|
-
# apply spacing after the text max of 100 characters so it doesn't show body text
|
219
|
-
preview_node.content += ' ' * [(100 - preview_node.content.length.to_i), 0].max
|
220
|
-
node = template('div', classes: 'preview', contents: preview_node.content)
|
221
|
-
preview_node.remove
|
222
|
-
node
|
223
|
-
end
|
224
|
-
end
|
13
|
+
if defined?(Rails)
|
14
|
+
require 'action_mailer'
|
225
15
|
end
|
226
16
|
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
17
|
+
require_relative 'bootstrap-email/initialize'
|
18
|
+
require_relative 'bootstrap-email/erb'
|
19
|
+
require_relative 'bootstrap-email/compiler'
|
20
|
+
require_relative 'bootstrap-email/sass_cache'
|
21
|
+
require_relative 'bootstrap-email/version'
|
22
|
+
require_relative 'bootstrap-email/components/base'
|
23
|
+
Dir[File.join(__dir__, 'bootstrap-email/components', '*.rb')].each { |file| require_relative file }
|
24
|
+
|
25
|
+
if defined?(Rails)
|
26
|
+
require_relative 'bootstrap-email/rails/action_mailer'
|
27
|
+
require_relative 'bootstrap-email/rails/engine'
|
28
|
+
end
|