mjml-rb 0.2.16 → 0.2.19
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/components/section.rb +22 -6
- data/lib/mjml-rb/components/table.rb +23 -0
- data/lib/mjml-rb/components/text.rb +23 -0
- 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: 12ea5b420bd39082c2111d56d58acc08c7f79a198e81a5d9b144cca8965ad90b
|
|
4
|
+
data.tar.gz: 7905538950c04f1d6973a77bdcff821ab14f75276a29258d20a6024f07ea586d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 851b51c74451340b5e25742f0966f21bbc1fb3b77dee2ec6eff6bc19846271dfbbf7e8fe7a35d71cf9ef9d119f8aa5558ae0c1cd281e90959e5c69ddb1d0545a
|
|
7
|
+
data.tar.gz: cfd996177dd6703317f5f67e7dd7634eb8b603721db54e5021a65e8930f764466d533b1f2c4effe0d7c76ae3574ebc03984a373c369b317384f9f0ba210ddbd4
|
|
@@ -29,6 +29,7 @@ module MjmlRb
|
|
|
29
29
|
}.freeze
|
|
30
30
|
|
|
31
31
|
WRAPPER_ALLOWED_ATTRIBUTES = SECTION_ALLOWED_ATTRIBUTES.merge(
|
|
32
|
+
"gap" => "unit(px)",
|
|
32
33
|
"full-width" => "enum(full-width)"
|
|
33
34
|
).freeze
|
|
34
35
|
|
|
@@ -294,6 +295,7 @@ module MjmlRb
|
|
|
294
295
|
bg_color = a["background-color"]
|
|
295
296
|
border_radius = a["border-radius"]
|
|
296
297
|
bg_has = has_background?(a)
|
|
298
|
+
wrapper_gap = context[:_wrapper_child_gap]
|
|
297
299
|
|
|
298
300
|
# Box width: container minus horizontal padding and borders
|
|
299
301
|
border_left = parse_border_width(a["border-left"] || a["border"])
|
|
@@ -311,7 +313,7 @@ module MjmlRb
|
|
|
311
313
|
["cellspacing", "0"],
|
|
312
314
|
["class", outlook_class],
|
|
313
315
|
["role", "presentation"],
|
|
314
|
-
["style", "width
|
|
316
|
+
["style", style_join("width" => "#{container_px}px", "padding-top" => wrapper_gap) + ";"],
|
|
315
317
|
["width", container_px.to_s]
|
|
316
318
|
]
|
|
317
319
|
before_pairs << ["bgcolor", bg_color] if bg_color
|
|
@@ -334,6 +336,7 @@ module MjmlRb
|
|
|
334
336
|
"background-repeat" => bg_repeat,
|
|
335
337
|
"background-size" => bg_size,
|
|
336
338
|
"margin" => "0px auto",
|
|
339
|
+
"margin-top" => wrapper_gap,
|
|
337
340
|
"max-width" => "#{container_px}px"
|
|
338
341
|
)
|
|
339
342
|
table_style = style_join(
|
|
@@ -365,6 +368,7 @@ module MjmlRb
|
|
|
365
368
|
"background" => bg_color,
|
|
366
369
|
"background-color" => bg_color,
|
|
367
370
|
"margin" => "0px auto",
|
|
371
|
+
"margin-top" => wrapper_gap,
|
|
368
372
|
"max-width" => "#{container_px}px"
|
|
369
373
|
)
|
|
370
374
|
table_style = style_join(
|
|
@@ -465,6 +469,7 @@ module MjmlRb
|
|
|
465
469
|
css_class = a["css-class"]
|
|
466
470
|
bg_color = a["background-color"]
|
|
467
471
|
full_width = a["full-width"] == "full-width"
|
|
472
|
+
wrapper_gap = context[:_wrapper_child_gap]
|
|
468
473
|
|
|
469
474
|
# renderBefore — same structure as section
|
|
470
475
|
outlook_class = css_class ? "#{css_class}-outlook" : ""
|
|
@@ -475,7 +480,7 @@ module MjmlRb
|
|
|
475
480
|
["cellspacing", "0"],
|
|
476
481
|
["class", outlook_class],
|
|
477
482
|
["role", "presentation"],
|
|
478
|
-
["style", "width
|
|
483
|
+
["style", style_join("width" => "#{container_px}px", "padding-top" => wrapper_gap) + ";"],
|
|
479
484
|
["width", container_px.to_s]
|
|
480
485
|
]
|
|
481
486
|
before_pairs << ["bgcolor", bg_color] if bg_color
|
|
@@ -486,6 +491,7 @@ module MjmlRb
|
|
|
486
491
|
"background" => bg_color,
|
|
487
492
|
"background-color" => bg_color,
|
|
488
493
|
"margin" => "0px auto",
|
|
494
|
+
"margin-top" => wrapper_gap,
|
|
489
495
|
"max-width" => (full_width ? nil : "#{container_px}px")
|
|
490
496
|
)
|
|
491
497
|
|
|
@@ -507,7 +513,7 @@ module MjmlRb
|
|
|
507
513
|
)
|
|
508
514
|
|
|
509
515
|
div_attrs = {"class" => css_class, "style" => div_style}
|
|
510
|
-
inner = merge_outlook_conditionals(render_wrapped_children_wrapper(node, context, container_px))
|
|
516
|
+
inner = merge_outlook_conditionals(render_wrapped_children_wrapper(node, context, container_px, a["gap"]))
|
|
511
517
|
|
|
512
518
|
wrapper_html =
|
|
513
519
|
%(<div#{html_attrs(div_attrs)}>) +
|
|
@@ -520,7 +526,7 @@ module MjmlRb
|
|
|
520
526
|
end
|
|
521
527
|
|
|
522
528
|
# Wrap each child mj-section/mj-wrapper in an Outlook conditional <td>.
|
|
523
|
-
def render_wrapped_children_wrapper(node, context, container_px)
|
|
529
|
+
def render_wrapped_children_wrapper(node, context, container_px, gap)
|
|
524
530
|
children = node.element_children.select { |e| %w[mj-section mj-wrapper].include?(e.tag_name) }
|
|
525
531
|
return render_children(node, context, parent: "mj-wrapper") if children.empty?
|
|
526
532
|
|
|
@@ -530,16 +536,26 @@ module MjmlRb
|
|
|
530
536
|
close_table = %(<!--[if mso | IE]></table><![endif]-->)
|
|
531
537
|
|
|
532
538
|
section_parts = with_inherited_mj_class(context, node) do
|
|
533
|
-
children.map do |child|
|
|
539
|
+
children.each_with_index.map do |child, index|
|
|
534
540
|
td_open = %(<!--[if mso | IE]><td class="" width="#{container_px}px" ><![endif]-->)
|
|
535
541
|
td_close = %(<!--[if mso | IE]></td><![endif]-->)
|
|
536
|
-
child_html =
|
|
542
|
+
child_html = with_wrapper_child_gap(context, index.zero? ? nil : gap) do
|
|
543
|
+
render_node(child, context, parent: "mj-wrapper")
|
|
544
|
+
end
|
|
537
545
|
"#{td_open}\n#{child_html}\n#{td_close}"
|
|
538
546
|
end
|
|
539
547
|
end
|
|
540
548
|
|
|
541
549
|
([open_table, open_tr] + section_parts + [close_tr, close_table]).join("\n")
|
|
542
550
|
end
|
|
551
|
+
|
|
552
|
+
def with_wrapper_child_gap(context, gap)
|
|
553
|
+
previous = context[:_wrapper_child_gap]
|
|
554
|
+
context[:_wrapper_child_gap] = gap
|
|
555
|
+
yield
|
|
556
|
+
ensure
|
|
557
|
+
context[:_wrapper_child_gap] = previous
|
|
558
|
+
end
|
|
543
559
|
end
|
|
544
560
|
end
|
|
545
561
|
end
|
|
@@ -5,6 +5,28 @@ module MjmlRb
|
|
|
5
5
|
class Table < Base
|
|
6
6
|
TAGS = ["mj-table"].freeze
|
|
7
7
|
|
|
8
|
+
ALLOWED_ATTRIBUTES = {
|
|
9
|
+
"align" => "enum(left,right,center)",
|
|
10
|
+
"border" => "string",
|
|
11
|
+
"cellpadding" => "string",
|
|
12
|
+
"cellspacing" => "string",
|
|
13
|
+
"color" => "color",
|
|
14
|
+
"container-background-color" => "color",
|
|
15
|
+
"font-family" => "string",
|
|
16
|
+
"font-size" => "string",
|
|
17
|
+
"font-weight" => "string",
|
|
18
|
+
"line-height" => "string",
|
|
19
|
+
"padding" => "unit(px,%){1,4}",
|
|
20
|
+
"padding-top" => "unit(px,%)",
|
|
21
|
+
"padding-right" => "unit(px,%)",
|
|
22
|
+
"padding-bottom" => "unit(px,%)",
|
|
23
|
+
"padding-left" => "unit(px,%)",
|
|
24
|
+
"role" => "string",
|
|
25
|
+
"table-layout" => "enum(auto,fixed)",
|
|
26
|
+
"vertical-align" => "enum(top,bottom,middle)",
|
|
27
|
+
"width" => "string"
|
|
28
|
+
}.freeze
|
|
29
|
+
|
|
8
30
|
DEFAULTS = {
|
|
9
31
|
"align" => "left",
|
|
10
32
|
"border" => "none",
|
|
@@ -49,6 +71,7 @@ module MjmlRb
|
|
|
49
71
|
"color" => a["color"],
|
|
50
72
|
"font-family" => a["font-family"],
|
|
51
73
|
"font-size" => a["font-size"],
|
|
74
|
+
"font-weight" => a["font-weight"],
|
|
52
75
|
"line-height" => a["line-height"],
|
|
53
76
|
"table-layout" => a["table-layout"],
|
|
54
77
|
"width" => a["width"],
|
|
@@ -5,6 +5,28 @@ module MjmlRb
|
|
|
5
5
|
class Text < Base
|
|
6
6
|
TAGS = ["mj-text"].freeze
|
|
7
7
|
|
|
8
|
+
ALLOWED_ATTRIBUTES = {
|
|
9
|
+
"align" => "enum(left,right,center,justify)",
|
|
10
|
+
"background-color" => "color",
|
|
11
|
+
"color" => "color",
|
|
12
|
+
"container-background-color" => "color",
|
|
13
|
+
"font-family" => "string",
|
|
14
|
+
"font-size" => "string",
|
|
15
|
+
"font-style" => "string",
|
|
16
|
+
"font-weight" => "string",
|
|
17
|
+
"height" => "string",
|
|
18
|
+
"letter-spacing" => "string",
|
|
19
|
+
"line-height" => "string",
|
|
20
|
+
"padding" => "unit(px,%){1,4}",
|
|
21
|
+
"padding-top" => "unit(px,%)",
|
|
22
|
+
"padding-right" => "unit(px,%)",
|
|
23
|
+
"padding-bottom" => "unit(px,%)",
|
|
24
|
+
"padding-left" => "unit(px,%)",
|
|
25
|
+
"text-decoration" => "string",
|
|
26
|
+
"text-transform" => "string",
|
|
27
|
+
"vertical-align" => "enum(top,bottom,middle)"
|
|
28
|
+
}.freeze
|
|
29
|
+
|
|
8
30
|
DEFAULTS = {
|
|
9
31
|
"align" => "left",
|
|
10
32
|
"color" => "#000000",
|
|
@@ -40,6 +62,7 @@ module MjmlRb
|
|
|
40
62
|
}
|
|
41
63
|
|
|
42
64
|
div_style = style_join(
|
|
65
|
+
"background-color" => a["background-color"],
|
|
43
66
|
"font-family" => a["font-family"],
|
|
44
67
|
"font-size" => a["font-size"],
|
|
45
68
|
"font-style" => a["font-style"],
|
data/lib/mjml-rb/version.rb
CHANGED