fx_awesome_mails 0.5.0 → 0.5.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 375f8fa975dff9c07d12784b3439f6a74c88f8f1a49a85842e48bfa77a2961dd
4
- data.tar.gz: 777a1952abc39060e94a0a4543b4f1d6ebb114563684b5f3cae21f9357c98bcc
3
+ metadata.gz: 182d15e812f86ce005073951b8a5a32ac647021bbe101bd0dd60def54db69982
4
+ data.tar.gz: 8e66c5acd82735c5cb52b26997dc3b6fa4a347e56651f8b787d028c3bfcb5d53
5
5
  SHA512:
6
- metadata.gz: e43af4e3a804d65197a058eb0a43353174c5804da05717e2bdcb4e113da3c0fc5903cf4315f8d9c3f10597b18ace97f4c585bbbbeffe909bdf3c3b83afeb8557
7
- data.tar.gz: a359826ca588ecacca6638d98351b34e7a3f02331817ec19083719bd2529216db4e06b3c22c47f2aaaea12826c935f25cca95e6dd64f640fb2c88289d5177e87
6
+ metadata.gz: 16c3566479da7798202aa7097063e99fb8d050c17633ceee5714486a48a3134e269fc33a3fc21283aa9a0704340b74e7b3c6dd217f3dde71e7ea9a74b3d5779c
7
+ data.tar.gz: 585762552a960b0383c56613a7b2fea161d4613b05f5e369ab8d0e23d5c3ced183ba2edc2a68d7830c799bf8a74e3f1bb8fe167120f5061e2d4c956c36159cae
@@ -0,0 +1,39 @@
1
+ module FXAwesomeMails
2
+ module CoreExtensions
3
+ module Hash
4
+ module Merging
5
+ def deep_merge_v2(second)
6
+ merger = proc { |_, v1, v2| Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : Array === v1 && Array === v2 ? v1 | v2 : [:undefined, nil, :nil].include?(v2) ? v1 : v2 }
7
+ merge(second.to_h, &merger)
8
+ end
9
+
10
+ def merge_email_options(second)
11
+ merger = proc { |k, v1, v2| Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : Array === v1 && Array === v2 ? v1 | v2 : [:undefined, nil, :nil].include?(v2) ? v1 : [:style, :class].include?(k) ? v1.merge_css_options(v2, k) : v2}
12
+ merge(second.to_h, &merger)
13
+ end
14
+ end
15
+ end
16
+
17
+ module String
18
+ module Merging
19
+ def merge_css_options(second, key)
20
+ return self&.strip if second.blank?
21
+ return second&.strip if self.blank?
22
+
23
+ case key
24
+ when :style
25
+ return self.strip.to_css_hash.deep_merge_v2(second.strip.to_css_hash).map {|k,v| [k,v].join(':') }.join(';')
26
+ when :class
27
+ self.strip.split(' ').union(second.strip.split(' ')).join(' ')
28
+ else
29
+ return ""
30
+ end
31
+ end
32
+
33
+ def to_css_hash
34
+ Hash[self.split(';').map { _1.split(':').map(&:strip) }]
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -1,3 +1,4 @@
1
+ require 'fx_awesome_mails/view_helpers'
1
2
  module FXAwesomeMails
2
3
  class Railtie < ::Rails::Railtie
3
4
  initializer "fx_awesome_mails.view_helpers" do
@@ -1,3 +1,3 @@
1
1
  module FXAwesomeMails
2
- VERSION = '0.5.0'
2
+ VERSION = '0.5.4'
3
3
  end
@@ -1,14 +1,19 @@
1
+ require 'fx_awesome_mails/core_extensions'
1
2
  module FXAwesomeMails
2
3
  module EmailHelpers
4
+
5
+ Hash.include FXAwesomeMails::CoreExtensions::Hash::Merging
6
+ String.include FXAwesomeMails::CoreExtensions::String::Merging
7
+
3
8
  def preheader(text)
4
9
  "<div style='display: none; max-height: 0px; overflow: hidden;'>
5
- #{text}
6
- </div>
7
- <div class='preheader' style='display: none; width: 0px; height: 0px; max-height: 0px; overflow: hidden;'>
8
- &#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;
9
- </div>".html_safe
10
+ #{text}
11
+ </div>
12
+ <div class='preheader' style='display: none; width: 0px; height: 0px; max-height: 0px; overflow: hidden;'>
13
+ &#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;&#847;&zwnj;&nbsp;
14
+ </div>".html_safe
10
15
  end
11
-
16
+
12
17
  def titlebar_link(link)
13
18
  "<div class='tac pt10 pb10 pl5 pr5'>
14
19
  <!--[if gte mso 12]><br><![endif]-->
@@ -16,12 +21,11 @@ module FXAwesomeMails
16
21
  <!--[if gte mso 12]><br><![endif]-->
17
22
  </div>".html_safe
18
23
  end
19
-
24
+
20
25
  def divider(options = {})
21
26
  "<p class='MsoNormal'><o:p>&nbsp;</o:p></p>".html_safe # TODO: options/smaller
22
27
  end
23
-
24
-
28
+
25
29
  # experimental mail helpers
26
30
  def content_tag_if(condition, name, content_or_options_with_block = {}, options = {}, escape = true, &block)
27
31
  options = content_or_options_with_block if content_or_options_with_block.is_a?(Hash) if block_given?
@@ -35,14 +39,14 @@ module FXAwesomeMails
35
39
  content_or_options_with_block, options = options, nil if block_given?
36
40
  content_tag(name, content_or_options_with_block, options, escape, &block)
37
41
  end
38
-
42
+
39
43
  def rounded_box(&block)
40
44
  html = "<div class='rounded_box'><div class='rounded_box_content'><div class='rounded_box_top'></div>"
41
45
  html << capture(:foo, :bar, &block)
42
46
  html << "<div class='rounded_box_bottom'><div></div></div></div>"
43
47
  raw html
44
48
  end
45
-
49
+
46
50
  # https://edgeapi.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-link_to_if + link_to( ...&block)
47
51
  def link_to_if_true(condition, name, options = {}, html_options = {}, &block)
48
52
  if condition
@@ -55,14 +59,14 @@ module FXAwesomeMails
55
59
  end
56
60
  end
57
61
  end
58
-
62
+
59
63
  class Button
60
64
  attr_accessor :parent
61
65
  def initialize(parent)
62
66
  self.parent = parent
63
67
  end
64
68
  delegate :capture, :content_tag, :link_to, :link_to_if, :link_to_if_true, :image_tag, :to => :parent
65
-
69
+
66
70
  # simple, graphical
67
71
  def simple_button(text = nil, type: :simple, **options, &block)
68
72
  html = "<th valign='bottom' style='text-align:left' class='buttoncellclass mobile-display-block button-container' bgcolor='#000000'>
@@ -73,7 +77,7 @@ module FXAwesomeMails
73
77
  <table cellpadding='0' cellspacing='0' border='0' width='auto' style='margin:0 auto' role='presentation' align='center'>
74
78
  <tbody>
75
79
  <tr>"
76
-
80
+
77
81
  # style = mso-line-height-rule: exactly; -webkit-border-radius:10px;-moz-border-radius:10px;border-radius:10px;background:#FFFF00;text-align:right
78
82
  # link_style = -webkit-border-radius: 10px; -moz-border-radius: 10px; border-radius: 10px; padding: 10px 20px; display: inline-block; text-decoration: none; text-align: right; color: #00FF00; border: 12; font-family: Arial, sans-serif; font-size: 13px; line-height: 14px; font-weight: 500;
79
83
  html << content_tag('th', valign: options[:valign].to_s, align: options[:align].to_s) do
@@ -90,24 +94,24 @@ module FXAwesomeMails
90
94
  </tbody>
91
95
  </table>
92
96
  </th>"
93
-
97
+
94
98
  html.html_safe
95
99
  end
96
-
100
+
97
101
  def graphical_button(text, type: :simple, **options, &block)
98
102
  "<th valign='bottom' style='text-align:left' class='buttoncellclass mobile-display-block button-container' bgcolor='#000000'>
99
103
  <table cellpadding='0' cellspacing='0' border='0' width='100%' style='width:100% !important' role='presentation'>
100
104
  <tbody>
101
105
  <tr>
102
-
106
+
103
107
 
104
-
108
+
105
109
  </tr>
106
110
  </tbody>
107
111
  </table>
108
112
  </th>"
109
113
  end
110
-
114
+
111
115
  def button(text = nil, type: :simple, **options)
112
116
  case type
113
117
  when :simple
@@ -116,7 +120,7 @@ module FXAwesomeMails
116
120
  graphical_button(text, **options)
117
121
  end
118
122
  end
119
-
123
+
120
124
  end
121
125
  class Gutter
122
126
  attr_accessor :parent
@@ -124,43 +128,43 @@ module FXAwesomeMails
124
128
  self.parent = parent
125
129
  end
126
130
  delegate :capture, :content_tag, :link_to, :link_to_if, :link_to_if_true, :image_tag, :to => :parent
127
-
131
+
128
132
  def horizontal(height = '20', **options)
129
- options = {valign: 'top', class: '',style: { "background-color" => '' }}.deep_merge_v2(options)
130
- content_tag('th', '&nbsp;'.html_safe, height: height, valign: "#{options[:valign]}", style: "#{options[:style]}", class: "#{options[:class]} horizontal-gutter", bgcolor: "#{options.dig(:style, "background-color")}")
133
+ options = {valign: 'top', class: '',style: ""}.merge_email_options(options)
134
+ content_tag('th', '&nbsp;'.html_safe, height: height, valign: "#{options[:valign]}", style: "#{options[:style]}", class: "#{options[:class]} horizontal-gutter", bgcolor: "#{options[:style].to_s.to_css_hash["background-color"]}")
131
135
  end
132
-
136
+
133
137
  def vertical(width = '20', **options)
134
- options = {valign: 'top', class: '',style: { "background-color" => '' }}.deep_merge_v2(options)
135
- content_tag('th', '&nbsp;'.html_safe, width: width, valign: "#{options[:valign]}", style: "#{options[:style]}", class: "#{options[:class]} vertical-gutter", bgcolor: "#{options.dig(:style, "background-color")}")
138
+ options = {valign: 'top', class: '',style: ""}.merge_email_options(options)
139
+ content_tag('th', '&nbsp;'.html_safe, width: width, valign: "#{options[:valign]}", style: "#{options[:style]}", class: "#{options[:class]} vertical-gutter", bgcolor: "#{options[:style].to_s.to_css_hash["background-color"]}")
136
140
  end
137
141
  end
138
-
142
+
139
143
  class Text
140
144
  attr_accessor :parent
141
145
  def initialize(parent)
142
146
  self.parent = parent
143
147
  end
144
148
  delegate :capture, :content_tag, :link_to, :link_to_if, :link_to_if_true, :image_tag, :to => :parent
145
-
149
+
146
150
  def text(text = nil, **options, &block)
147
- options = {"mso-line-height-rule" => "exactly", "text-align" => "center", "font-family" => "Helvetica", "font-size" => "20px", "line-height" => "30px", "font-weight" => "400", color: "#000000", "background-color" => "#FF00FF"}.deep_merge_v2(options)
148
- content_tag('th', valign: "#{options[:valign]}", style: options[:style], class: "#{options[:class]} text-container", bgcolor: "#{options.dig(:style, "background-color")}") do
151
+ options = {style: "mso-line-height-rule:exactly;text-align:left;font-weight:400"}.merge_email_options(options)
152
+ content_tag('th', valign: "#{options[:valign]}", style: options[:style], class: "#{options[:class]} text-container", bgcolor: "#{options[:style].to_s.to_css_hash["background-color"]}") do
149
153
  "#{block_given? ? capture(&block) : text}".html_safe
150
154
  end
151
155
  end
152
156
  end
153
-
157
+
154
158
  class Image
155
159
  attr_accessor :parent
156
160
  def initialize(parent)
157
161
  self.parent = parent
158
162
  end
159
163
  delegate :capture, :content_tag, :link_to, :link_to_if, :link_to_if_true, :image_tag, :to => :parent
160
-
164
+
161
165
  def email_image_tag(source: nil, **options, &block)
162
- options = {alt: '', link_url: nil, width: 130, height: 50, valign: 'top', align: 'left', class: '', style: {"background-color" => "#FFFFFF", outline: "none", "text-decoration" => "none", "-ms-interpolation-mode" => "bicubic", display: "block", border: "none"} }.deep_merge_v2(options)
163
- html = "<th valign='#{options[:avlign]}' style='text-align:left' class='#{options[:class]} mobile-display-table-footer-group image-container' bgcolor='#{options.dig(:style, "background-color")}' align='#{options[:align]}'>"
166
+ options = {alt: '', link_url: nil, width: 130, height: 50, valign: 'top', align: 'left', class: '', style: "background-color: #FFFFFF;outline: none; text-decoration: none; -ms-interpolation-mode: bicubic; display: block; border: none" }.merge_email_options(options)
167
+ html = "<th valign='#{options[:avlign]}' style='text-align:left' class='#{options[:class]} mobile-display-table-footer-group image-container' bgcolor='#{options[:style].to_s.to_css_hash["background-color"]}' align='#{options[:align]}'>"
164
168
  html << link_to_if_true(options[:link_url].present?, options[:link_url], target: '_blank') do
165
169
  image_tag(source, style: options[:style], width: "#{options[:width]}", height: "#{options[:height]}", alt: "#{options[:alt]}")
166
170
  end
@@ -169,60 +173,61 @@ module FXAwesomeMails
169
173
  html.html_safe
170
174
  end
171
175
  end
172
-
173
-
176
+
177
+
174
178
  class VerticalGrid
175
179
  attr_accessor :parent
176
180
  def initialize(parent)
177
181
  self.parent = parent
178
182
  end
179
183
  delegate :capture, :content_tag, :link_to, :link_to_if, :link_to_if_true, :image_tag, :to => :parent
180
-
184
+
181
185
  def self.vertical_grid(_capture_helper, **options, &block)
182
- "<th valign='top' style='text-align:left' class='vertical-grid'>
183
- <table cellpadding='0' cellspacing='0' border='0' width='100%' style='min-width:100%' role='presentation'>
186
+ options = { valign: 'top', style: "text-align: left" }.merge_email_options(options)
187
+ _capture_helper.content_tag('th', valign: "#{options[:valign]}", style: "#{options[:style]}", class: "text-container #{options[:class]}") do
188
+ "<table cellpadding='0' cellspacing='0' border='0' width='100%' style='min-width:100%' role='presentation'>
184
189
  <tbody>
185
190
  #{_capture_helper.capture(VerticalGrid.new(_capture_helper), &block)}
186
191
  </tbody>
187
- </table>
188
- </th>".html_safe
192
+ </table>".html_safe
193
+ end
189
194
  end
190
-
195
+
191
196
  def gutter(...)
192
197
  "<tr>#{Gutter.new(parent).horizontal(...)}</tr>".html_safe
193
198
  end
194
-
199
+
195
200
  def text(text = nil, **options, &block)
196
201
  "<tr>#{Text.new(parent).text(text, **options, &block)}</tr>".html_safe
197
202
  end
198
-
203
+
199
204
  def image(...)
200
205
  "<tr>#{Image.new(parent).email_image_tag(...)}</tr>".html_safe
201
206
  end
202
-
207
+
203
208
  def button(...)
204
209
  "<tr>
205
210
  #{Button.new(parent).button(...)}
206
211
  </tr>".html_safe
207
212
  end
208
-
213
+
209
214
  def horizontal_grid(**options, &block)
210
215
  "<tr>#{HorizontalGrid.horizontal_grid(parent, **options, &block)}</tr>".html_safe
211
216
  end
212
-
217
+
213
218
  def vertical_grid(**options, &block)
214
219
  "<tr>#{VerticalGrid.vertical_grid(parent, **options, &block)}</tr>".html_safe
215
220
  end
216
221
  end
217
-
218
-
222
+
223
+
219
224
  class HorizontalGrid
220
225
  attr_accessor :parent
221
226
  def initialize(parent)
222
227
  self.parent = parent
223
228
  end
224
229
  delegate :capture, :content_tag, :link_to, :link_to_if, :link_to_if_true, :image_tag, :to => :parent
225
-
230
+
226
231
  def self.horizontal_grid(_capture_helper, **options, &block)
227
232
  "<th valign='top' style='text-align:left' class='horizontal-grid'>
228
233
  <table cellpadding='0' cellspacing='0' border='0' width='100%' style='min-width:100%' role='presentation'>
@@ -234,22 +239,22 @@ module FXAwesomeMails
234
239
  </table>
235
240
  </th>".html_safe
236
241
  end
237
-
242
+
238
243
  def gutter(...)
239
244
  "#{Gutter.new(parent).vertical(...)}".html_safe
240
245
  end
241
-
246
+
242
247
  def text(text = nil, **options, &block)
243
- options = { valign: 'top', style: { "mso-line-height-rule" => "exactly", "text-align" => "left", "font-family" => "Arial, sans-serif", "font-size" => "15px", "line-height" => "18px", "font-weight" => "normal", color: "#999999" }}.deep_merge_v2(options)
244
- content_tag('th', valign: "#{options[:valign]}", style: "#{options[:style]}", class: "#{options[:class]} text-container") do
248
+ options = { valign: 'top', style: "mso-line-height-rule: exactly; text-align: left; font-family: Arial, sans-serif; font-size: 15px; line-height: 18px; font-weight: normal; color: #999999" }.merge_email_options(options)
249
+ content_tag('th', valign: "#{options[:valign]}", style: "#{options[:style]}", class: "text-container #{options[:class]}") do
245
250
  block_given? ? capture(&block) : text
246
251
  end
247
252
  end
248
-
253
+
249
254
  def image(...)
250
255
  "#{Image.new(parent).email_image_tag(...)}".html_safe
251
256
  end
252
-
257
+
253
258
  def button
254
259
  "<th valign='top' style='text-align:left' class='button-container'>
255
260
  <table cellpadding='0' cellspacing='0' border='0' width='100%' style='width:100% !important' role='presentation'>
@@ -269,28 +274,28 @@ module FXAwesomeMails
269
274
  </table>
270
275
  </th>".hmtl_safe
271
276
  end
272
-
277
+
273
278
  def horizontal_grid(**options, &block)
274
279
  "#{HorizontalGrid.horizontal_grid(parent, **options, &block)}".html_safe
275
280
  end
276
-
281
+
277
282
  def vertical_grid(**options, &block)
278
283
  "#{VerticalGrid.vertical_grid(parent, **options, &block)}".html_safe
279
284
  end
280
-
285
+
281
286
  end
282
-
287
+
283
288
  class ContentTable
284
-
289
+
285
290
  attr_accessor :parent
286
291
  def initialize(parent)
287
292
  self.parent = parent
288
293
  end
289
294
  delegate :capture, :content_tag, :link_to, :link_to_if, :link_to_if_true, :image_tag, :to => :parent
290
-
295
+
291
296
  def self.content_table(_capture_helper, **options, &block)
292
- options = {alt: '', link_url: nil, width: 600, height: 50, valign: 'top', align: 'left', class: '', background: '', style: {"background-color" => "#FFFFFF" } }.deep_merge_v2(options)
293
- "<table cellpadding='0' cellspacing='0' border='0' width='#{options[:width]}' style='margin: 0; padding: 0; text-align: left; width: 100%; min-width: 600px; line-height: 100%;' role='presentation' background='#{options[:background]}' class='background-table has-width-#{options[:width]}' bgcolor='#{options.dig(:style, "background-color")}' valign='top'>
297
+ options = {alt: '', link_url: nil, width: 600, height: 50, valign: 'top', align: 'left', class: '', background: '', style: "background-color: #FFFFFF" }.merge_email_options(options)
298
+ "<table cellpadding='0' cellspacing='0' border='0' width='#{options[:width]}' style='margin: 0; padding: 0; text-align: left; width: 100%; min-width: 600px; line-height: 100%;' role='presentation' background='#{options[:background]}' class='background-table has-width-#{options[:width]}' bgcolor='#{options[:style].to_s.to_css_hash["background-color"]}' valign='top'>
294
299
  <tbody>
295
300
  <tr>
296
301
  <th valign='top'>
@@ -310,7 +315,7 @@ module FXAwesomeMails
310
315
  </tbody>
311
316
  </table>".html_safe
312
317
  end
313
-
318
+
314
319
  def text(...)
315
320
  "<div>
316
321
  <table cellpadding='0' cellspacing='0' border='0' width='100%' style='min-width:100%' role='presentation'>
@@ -334,13 +339,13 @@ module FXAwesomeMails
334
339
  </table>
335
340
  </div>".html_safe
336
341
  end
337
-
342
+
338
343
  def button
339
344
  "<div>
340
345
  <table cellpadding='0' cellspacing='0' border='0' width='100%' style='min-width:100%' role='presentation'>
341
346
  <tbody>
342
347
  <tr>
343
-
348
+
344
349
  <th valign='top' style='text-align:left' class='button-container'>
345
350
  <table cellpadding='0' cellspacing='0' border='0' width='100%' style='width:100% !important' role='presentation'>
346
351
  <tbody>
@@ -358,13 +363,13 @@ module FXAwesomeMails
358
363
  </tbody>
359
364
  </table>
360
365
  </th>
361
-
366
+
362
367
  </tr>
363
368
  </tbody>
364
369
  </table>
365
370
  </div>".html_safe
366
371
  end
367
-
372
+
368
373
  def gutter(...)
369
374
  # only horizontal
370
375
  "<div>
@@ -377,7 +382,7 @@ module FXAwesomeMails
377
382
  </table>
378
383
  </div>".html_safe
379
384
  end
380
-
385
+
381
386
  def horizontal_grid(**options, &block)
382
387
  "<div>
383
388
  <table cellpadding='0' cellspacing='0' border='0' width='100%' style='min-width:100%' role='presentation'>
@@ -389,7 +394,7 @@ module FXAwesomeMails
389
394
  </table>
390
395
  </div>".html_safe
391
396
  end
392
-
397
+
393
398
  def vertical_grid(**options, &block)
394
399
  "<div>
395
400
  <table cellpadding='0' cellspacing='0' border='0' width='100%' style='min-width:100%' role='presentation'>
@@ -401,7 +406,7 @@ module FXAwesomeMails
401
406
  </table>
402
407
  </div>".html_safe
403
408
  end
404
-
409
+
405
410
  # def content(**options, &block)
406
411
  # "<div>
407
412
  # <table cellpadding='0' cellspacing='0' border='0' width='100%' style='min-width:100%' role='presentation'>
@@ -413,7 +418,7 @@ module FXAwesomeMails
413
418
  # </table>
414
419
  # </div>".html_safe
415
420
  # end
416
-
421
+
417
422
  end
418
423
 
419
424
  def content_table(**options, &block)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fx_awesome_mails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Felix Gebhard
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-24 00:00:00.000000000 Z
11
+ date: 2021-10-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -40,6 +40,7 @@ files:
40
40
  - README.md
41
41
  - Rakefile
42
42
  - lib/fx_awesome_mails.rb
43
+ - lib/fx_awesome_mails/core_extensions.rb
43
44
  - lib/fx_awesome_mails/railtie.rb
44
45
  - lib/fx_awesome_mails/version.rb
45
46
  - lib/fx_awesome_mails/view_helpers.rb