bootstrap-email 0.0.0.alpha.2 → 0.0.0.alpha.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d697ca73b6f0d8dd482151f4fefb5362100bf574
4
- data.tar.gz: 98fdfe5fe8d602cf595750bdad3a123799667db6
3
+ metadata.gz: 6626edeccebaeb79cf3379e238248b0008555129
4
+ data.tar.gz: 7d3a30dc676d0e966edb6d14e53fc5566c28ff21
5
5
  SHA512:
6
- metadata.gz: 6d2fc92efb6f6c04e261e3d306dc488c17ef0f17f40b686409b5a58c2d918acf3cd262352063c840880774285597f7222abfe17d178935247979d68258f3e4e4
7
- data.tar.gz: 79aa08506d89efbc8856f15fde6e306e7c38ca5957065fa9a95373e467d3a8abe5097c253b0d11b438d8ce718236481a8433052198fac8aa6beac6ddffc8ed62
6
+ metadata.gz: c5f4908da0bacacadd52579445da402dfc77c7b33bf5110275a46f2e9e894ef5ebf206f0e82ed234c1c73e12533a4d90d2f9b707c545b5df83d340348b6519ba
7
+ data.tar.gz: ae9e907d9bd67181cac294e60f1f45500c6402b589ac70ec1a08fd4526bc0fb48f72f2f31b4c8a71c2b31df8f122d46317c14ab87e710e06f95e3567a9f719f5
@@ -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
- Nokogiri::HTML::DocumentFragment.parse(ERB.new(template).result(namespace.instance_eval { binding }))
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-left', {classes: node['class'], contents: node.delete('class') && node.to_html}))
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'].sub(padding_regex, '')
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*=mr-], *[class*=mb-], *[class*=ml-], *[class*=mx-], *[class*=my-]') do |node|
128
- if node.name != 'div' # if it is already on a div, set the margin on the div, else wrap the content in a div
129
- margin_regex = /(m[trblxy]?-\d)/
130
- classes = node['class'].scan(margin_regex).join(' ')
131
- node['class'] = node['class'].sub(margin_regex, '')
132
- node.replace(build_from_template('div', {classes: classes, contents: node.to_html}))
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
 
@@ -1,5 +1,5 @@
1
1
  module BootstrapEmail
2
2
  module Rails
3
- VERSION = '0.0.0.alpha.2'
3
+ VERSION = '0.0.0.alpha.3'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bootstrap-email
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0.alpha.2
4
+ version: 0.0.0.alpha.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stuart Yamartino