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 +4 -4
- data/lib/mjml-rb/renderer.rb +45 -7
- data/lib/mjml-rb/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4abe3f3fbe1a4c05983bb09cb4be09e4043782a7ebfa47559237c046f96b8a4d
|
|
4
|
+
data.tar.gz: 14b40fb3904aa74c29bf48f5e1d2dcaed5eb304691ed4637ac37f8f53fe6ba8f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 35d3346d23f26f0436ee068a97889540a7090f8cc488a4c3051e8d97e7f28650bd465f8782c0dc57c4a0bf38668262249112f968f6dfb8611666a8eb926ad485
|
|
7
|
+
data.tar.gz: ca1188c564dc67a00218cd36c080f9550977a3a5a807c938bbbfa257940a85e1f9591834eea81b7c85b2eba8ad8f88c4ece92ab94db25c63ed6e981806d2357c
|
data/lib/mjml-rb/renderer.rb
CHANGED
|
@@ -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 = {
|
|
94
|
-
|
|
95
|
-
"
|
|
96
|
-
"
|
|
97
|
-
"
|
|
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
|
-
|
|
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)
|
data/lib/mjml-rb/version.rb
CHANGED