mjml-rb 0.2.20 → 0.2.21

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: 97ca7a3d968fdd4dee9f34ef7806283cb1a53fda0810dcf2456770f298831b35
4
- data.tar.gz: 53a50ac16e06c719fa6533de98e43c35233a1ab0470bf81c366c1be62726c2b4
3
+ metadata.gz: 4abe3f3fbe1a4c05983bb09cb4be09e4043782a7ebfa47559237c046f96b8a4d
4
+ data.tar.gz: 14b40fb3904aa74c29bf48f5e1d2dcaed5eb304691ed4637ac37f8f53fe6ba8f
5
5
  SHA512:
6
- metadata.gz: 22bb47ef2611887dbf6a19ee38cfb7da366060b632bf3cfb9ea548798a29e120287ae4de035255560d36dc5c407eeef3c04a007695b297da9230ecbd17d0dcb1
7
- data.tar.gz: f9f14bde5dd817a322e40da7b0de8645185c6b25e884d9d3aa45df7f3a5fca94eb92723204f4a193fc696bfe93f1b31a2033bf99042a3637adc7d0d61aa65343
6
+ metadata.gz: 35d3346d23f26f0436ee068a97889540a7090f8cc488a4c3051e8d97e7f28650bd465f8782c0dc57c4a0bf38668262249112f968f6dfb8611666a8eb926ad485
7
+ data.tar.gz: ca1188c564dc67a00218cd36c080f9550977a3a5a807c938bbbfa257940a85e1f9591834eea81b7c85b2eba8ad8f88c4ece92ab94db25c63ed6e981806d2357c
@@ -36,6 +36,27 @@ module MjmlRb
36
36
  p { display:block;margin:13px 0; }
37
37
  CSS
38
38
 
39
+ OUTLOOK_DOCUMENT_SETTINGS = <<~HTML.chomp.freeze
40
+ <!--[if mso]>
41
+ <noscript>
42
+ <xml>
43
+ <o:OfficeDocumentSettings>
44
+ <o:AllowPNG/>
45
+ <o:PixelsPerInch>96</o:PixelsPerInch>
46
+ </o:OfficeDocumentSettings>
47
+ </xml>
48
+ </noscript>
49
+ <![endif]-->
50
+ HTML
51
+
52
+ OUTLOOK_GROUP_FIX = <<~HTML.chomp.freeze
53
+ <!--[if lte mso 11]>
54
+ <style type="text/css">
55
+ .mj-outlook-group-fix { width:100% !important; }
56
+ </style>
57
+ <![endif]-->
58
+ HTML
59
+
39
60
  def render(document, options = {})
40
61
  head = find_child(document, "mj-head")
41
62
  body = find_child(document, "mj-body")
@@ -90,20 +111,28 @@ module MjmlRb
90
111
  before_doctype = context[:before_doctype].to_s
91
112
  font_tags = build_font_tags(content, context[:inline_styles], context[:fonts])
92
113
  preview_block = preview.empty? ? "" : %(<div style="display:none;max-height:0;overflow:hidden;opacity:0;">#{escape_html(preview)}</div>)
93
- html_attributes = { "lang" => context[:lang], "dir" => context[:dir] }
94
- body_style = style_join(
95
- "margin" => "0",
96
- "padding" => "0",
97
- "background" => context[:background_color] || "#ffffff"
98
- )
114
+ html_attributes = {
115
+ "lang" => context[:lang],
116
+ "dir" => context[:dir],
117
+ "xmlns" => "http://www.w3.org/1999/xhtml",
118
+ "xmlns:v" => "urn:schemas-microsoft-com:vml",
119
+ "xmlns:o" => "urn:schemas-microsoft-com:office:office"
120
+ }
121
+ body_style = style_join("word-spacing" => "normal")
99
122
 
100
123
  html = <<~HTML
101
124
  <!doctype html>
102
125
  <html#{html_attrs(html_attributes)}>
103
126
  <head>
127
+ <title>#{escape_html(title)}</title>
128
+ <!--[if !mso]><!-->
129
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
130
+ <!--<![endif]-->
131
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
104
132
  <meta charset="utf-8">
105
133
  <meta name="viewport" content="width=device-width, initial-scale=1">
106
- <title>#{escape_html(title)}</title>
134
+ #{OUTLOOK_DOCUMENT_SETTINGS}
135
+ #{OUTLOOK_GROUP_FIX}
107
136
  #{font_tags}
108
137
  <style type="text/css">#{head_styles}</style>
109
138
  #{head_raw}
@@ -202,12 +231,21 @@ module MjmlRb
202
231
  css = widths.map do |suffix, pct|
203
232
  ".mj-column-per-#{suffix} { width:#{pct}% !important; max-width: #{pct}%; }"
204
233
  end.join("\n")
234
+ moz_css = widths.map do |suffix, pct|
235
+ ".moz-text-html .mj-column-per-#{suffix} { width:#{pct}% !important; max-width: #{pct}%; }"
236
+ end.join("\n")
237
+ owa_css = widths.map do |suffix, pct|
238
+ "[owa] .mj-column-per-#{suffix} { width:#{pct}% !important; max-width: #{pct}%; }"
239
+ end.join("\n")
205
240
  breakpoint = context[:breakpoint].to_s.strip
206
241
  if breakpoint.empty?
207
242
  context[:head_styles] << css
243
+ context[:head_styles] << moz_css
208
244
  else
209
245
  context[:head_styles] << "@media only screen and (min-width:#{breakpoint}) {\n#{css}\n}"
246
+ context[:head_styles] << "@media screen and (min-width:#{breakpoint}) {\n#{moz_css}\n}"
210
247
  end
248
+ context[:head_styles] << owa_css
211
249
  end
212
250
 
213
251
  def merge_outlook_conditionals(html)
@@ -1,3 +1,3 @@
1
1
  module MjmlRb
2
- VERSION = "0.2.20".freeze
2
+ VERSION = "0.2.21".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mjml-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.20
4
+ version: 0.2.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrei Andriichuk