bootstrap-email 0.0.0.alpha.2 → 0.0.0.alpha.3
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/lib/bootstrap-email.rb +22 -9
- data/lib/bootstrap-email/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6626edeccebaeb79cf3379e238248b0008555129
|
4
|
+
data.tar.gz: 7d3a30dc676d0e966edb6d14e53fc5566c28ff21
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c5f4908da0bacacadd52579445da402dfc77c7b33bf5110275a46f2e9e894ef5ebf206f0e82ed234c1c73e12533a4d90d2f9b707c545b5df83d340348b6519ba
|
7
|
+
data.tar.gz: ae9e907d9bd67181cac294e60f1f45500c6402b589ac70ec1a08fd4526bc0fb48f72f2f31b4c8a71c2b31df8f122d46317c14ab87e710e06f95e3567a9f719f5
|
data/lib/bootstrap-email.rb
CHANGED
@@ -25,6 +25,7 @@ module BootstrapEmail
|
|
25
25
|
grid
|
26
26
|
padding
|
27
27
|
margin
|
28
|
+
spacer
|
28
29
|
table
|
29
30
|
end
|
30
31
|
|
@@ -38,7 +39,7 @@ module BootstrapEmail
|
|
38
39
|
def build_from_template template, locals_hash = {}
|
39
40
|
namespace = OpenStruct.new(locals_hash)
|
40
41
|
template = File.open(File.expand_path("../core/templates/#{template}.html.erb", __dir__)).read
|
41
|
-
|
42
|
+
ERB.new(template).result(namespace.instance_eval { binding })
|
42
43
|
end
|
43
44
|
|
44
45
|
def each_node css_lookup, &blk
|
@@ -48,7 +49,7 @@ module BootstrapEmail
|
|
48
49
|
|
49
50
|
def button
|
50
51
|
each_node('.btn') do |node| # move all classes up and remove all classes from the element
|
51
|
-
node.replace(build_from_template('table
|
52
|
+
node.replace(build_from_template('table', {classes: node['class'], contents: node.delete('class') && node.to_html}))
|
52
53
|
end
|
53
54
|
end
|
54
55
|
|
@@ -117,20 +118,32 @@ module BootstrapEmail
|
|
117
118
|
if node.name != 'table' # if it is already on a table, set the padding on the table, else wrap the content in a table
|
118
119
|
padding_regex = /(p[trblxy]?-\d)/
|
119
120
|
classes = node['class'].scan(padding_regex).join(' ')
|
120
|
-
node['class'] = node['class'].
|
121
|
+
node['class'] = node['class'].gsub(padding_regex, '')
|
121
122
|
node.replace(build_from_template('table', {classes: classes, contents: node.to_html}))
|
122
123
|
end
|
123
124
|
end
|
124
125
|
end
|
125
126
|
|
126
127
|
def margin
|
127
|
-
each_node('*[class*=m-], *[class*=mt-], *[class*=
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
128
|
+
each_node('*[class*=m-], *[class*=mt-], *[class*=mb-]') do |node|
|
129
|
+
top_class = node['class'][/m[t]?-(\d)/]
|
130
|
+
bottom_class = node['class'][/m[b]?-(\d)/]
|
131
|
+
node['class'] = node['class'].gsub(/(m[trblxy]?-\d)/, '')
|
132
|
+
html = ''
|
133
|
+
if top_class
|
134
|
+
html += build_from_template('div', {classes: "s-#{top_class.gsub(/m[t]?-/, '')}", contents: nil})
|
135
|
+
end
|
136
|
+
html += node.to_html
|
137
|
+
if bottom_class
|
138
|
+
html += build_from_template('div', {classes: "s-#{bottom_class.gsub(/m[b]?-/, '')}", contents: nil})
|
133
139
|
end
|
140
|
+
node.replace(html)
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
def spacer
|
145
|
+
each_node('*[class*=s-]') do |node|
|
146
|
+
node.replace(build_from_template('table', {classes: node['class'] + ' w-100', contents: " "}))
|
134
147
|
end
|
135
148
|
end
|
136
149
|
|