mjml-rb 0.2.26 → 0.2.28
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/accordion.rb +77 -0
- data/lib/mjml-rb/components/button.rb +36 -0
- data/lib/mjml-rb/components/divider.rb +14 -0
- data/lib/mjml-rb/components/image.rb +32 -0
- data/lib/mjml-rb/validator.rb +5 -1
- 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: d26c85019dd29ae196f94e69312c51874ee3fe9feccab39d74c0e91442c60746
|
|
4
|
+
data.tar.gz: 4bda9f651c55981d6a899a65ac97fafe73c98c85552c1d6c121c93c40ce1ab0d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 34a1e8d518b0e7a650ee34505070344fc8c4509e9ccb54bb76eb7032a2a12071d3d5b8b5d8587a86ba4e94f83703f68d841896bbf6260595cc921affe0267fb5
|
|
7
|
+
data.tar.gz: 6718b0725c742ef05549cc32301a26a7012afb238da2d796ce1c6b4c54d66cc015fc7e0ae723953b8cd3972a9a7fbcfc914b69c52fdaed50bc8b758c639e5d12
|
|
@@ -10,6 +10,83 @@ module MjmlRb
|
|
|
10
10
|
mj-accordion-text
|
|
11
11
|
].freeze
|
|
12
12
|
|
|
13
|
+
ACCORDION_ALLOWED_ATTRIBUTES = {
|
|
14
|
+
"container-background-color" => "color",
|
|
15
|
+
"border" => "string",
|
|
16
|
+
"font-family" => "string",
|
|
17
|
+
"icon-align" => "enum(top,middle,bottom)",
|
|
18
|
+
"icon-width" => "unit(px,%)",
|
|
19
|
+
"icon-height" => "unit(px,%)",
|
|
20
|
+
"icon-wrapped-url" => "string",
|
|
21
|
+
"icon-wrapped-alt" => "string",
|
|
22
|
+
"icon-unwrapped-url" => "string",
|
|
23
|
+
"icon-unwrapped-alt" => "string",
|
|
24
|
+
"icon-position" => "enum(left,right)",
|
|
25
|
+
"padding-bottom" => "unit(px,%)",
|
|
26
|
+
"padding-left" => "unit(px,%)",
|
|
27
|
+
"padding-right" => "unit(px,%)",
|
|
28
|
+
"padding-top" => "unit(px,%)",
|
|
29
|
+
"padding" => "unit(px,%){1,4}"
|
|
30
|
+
}.freeze
|
|
31
|
+
|
|
32
|
+
ACCORDION_ELEMENT_ALLOWED_ATTRIBUTES = {
|
|
33
|
+
"background-color" => "color",
|
|
34
|
+
"border" => "string",
|
|
35
|
+
"font-family" => "string",
|
|
36
|
+
"icon-align" => "enum(top,middle,bottom)",
|
|
37
|
+
"icon-width" => "unit(px,%)",
|
|
38
|
+
"icon-height" => "unit(px,%)",
|
|
39
|
+
"icon-wrapped-url" => "string",
|
|
40
|
+
"icon-wrapped-alt" => "string",
|
|
41
|
+
"icon-unwrapped-url" => "string",
|
|
42
|
+
"icon-unwrapped-alt" => "string",
|
|
43
|
+
"icon-position" => "enum(left,right)"
|
|
44
|
+
}.freeze
|
|
45
|
+
|
|
46
|
+
ACCORDION_TITLE_ALLOWED_ATTRIBUTES = {
|
|
47
|
+
"background-color" => "color",
|
|
48
|
+
"color" => "color",
|
|
49
|
+
"font-size" => "unit(px)",
|
|
50
|
+
"font-family" => "string",
|
|
51
|
+
"font-weight" => "string",
|
|
52
|
+
"padding-bottom" => "unit(px,%)",
|
|
53
|
+
"padding-left" => "unit(px,%)",
|
|
54
|
+
"padding-right" => "unit(px,%)",
|
|
55
|
+
"padding-top" => "unit(px,%)",
|
|
56
|
+
"padding" => "unit(px,%){1,4}"
|
|
57
|
+
}.freeze
|
|
58
|
+
|
|
59
|
+
ACCORDION_TEXT_ALLOWED_ATTRIBUTES = {
|
|
60
|
+
"background-color" => "color",
|
|
61
|
+
"font-size" => "unit(px)",
|
|
62
|
+
"font-family" => "string",
|
|
63
|
+
"font-weight" => "string",
|
|
64
|
+
"letter-spacing" => "unit(px,em)",
|
|
65
|
+
"line-height" => "unit(px,%,)",
|
|
66
|
+
"color" => "color",
|
|
67
|
+
"padding-bottom" => "unit(px,%)",
|
|
68
|
+
"padding-left" => "unit(px,%)",
|
|
69
|
+
"padding-right" => "unit(px,%)",
|
|
70
|
+
"padding-top" => "unit(px,%)",
|
|
71
|
+
"padding" => "unit(px,%){1,4}"
|
|
72
|
+
}.freeze
|
|
73
|
+
|
|
74
|
+
class << self
|
|
75
|
+
def allowed_attributes_for(tag_name)
|
|
76
|
+
case tag_name
|
|
77
|
+
when "mj-accordion" then ACCORDION_ALLOWED_ATTRIBUTES
|
|
78
|
+
when "mj-accordion-element" then ACCORDION_ELEMENT_ALLOWED_ATTRIBUTES
|
|
79
|
+
when "mj-accordion-title" then ACCORDION_TITLE_ALLOWED_ATTRIBUTES
|
|
80
|
+
when "mj-accordion-text" then ACCORDION_TEXT_ALLOWED_ATTRIBUTES
|
|
81
|
+
else {}
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def allowed_attributes
|
|
86
|
+
ACCORDION_ALLOWED_ATTRIBUTES
|
|
87
|
+
end
|
|
88
|
+
end
|
|
89
|
+
|
|
13
90
|
HEAD_STYLE = <<~CSS.freeze
|
|
14
91
|
noinput.mj-accordion-checkbox { display:block!important; }
|
|
15
92
|
@media yahoo, only screen and (min-width:0) {
|
|
@@ -5,6 +5,42 @@ module MjmlRb
|
|
|
5
5
|
class Button < Base
|
|
6
6
|
TAGS = ["mj-button"].freeze
|
|
7
7
|
|
|
8
|
+
ALLOWED_ATTRIBUTES = {
|
|
9
|
+
"align" => "enum(left,center,right)",
|
|
10
|
+
"background-color" => "color",
|
|
11
|
+
"border-bottom" => "string",
|
|
12
|
+
"border-left" => "string",
|
|
13
|
+
"border-radius" => "string",
|
|
14
|
+
"border-right" => "string",
|
|
15
|
+
"border-top" => "string",
|
|
16
|
+
"border" => "string",
|
|
17
|
+
"color" => "color",
|
|
18
|
+
"container-background-color" => "color",
|
|
19
|
+
"font-family" => "string",
|
|
20
|
+
"font-size" => "unit(px)",
|
|
21
|
+
"font-style" => "string",
|
|
22
|
+
"font-weight" => "string",
|
|
23
|
+
"height" => "unit(px,%)",
|
|
24
|
+
"href" => "string",
|
|
25
|
+
"name" => "string",
|
|
26
|
+
"title" => "string",
|
|
27
|
+
"inner-padding" => "unit(px,%){1,4}",
|
|
28
|
+
"letter-spacing" => "unit(px,em)",
|
|
29
|
+
"line-height" => "unit(px,%,)",
|
|
30
|
+
"padding-bottom" => "unit(px,%)",
|
|
31
|
+
"padding-left" => "unit(px,%)",
|
|
32
|
+
"padding-right" => "unit(px,%)",
|
|
33
|
+
"padding-top" => "unit(px,%)",
|
|
34
|
+
"padding" => "unit(px,%){1,4}",
|
|
35
|
+
"rel" => "string",
|
|
36
|
+
"target" => "string",
|
|
37
|
+
"text-decoration" => "string",
|
|
38
|
+
"text-transform" => "string",
|
|
39
|
+
"vertical-align" => "enum(top,bottom,middle)",
|
|
40
|
+
"text-align" => "enum(left,right,center)",
|
|
41
|
+
"width" => "unit(px,%)"
|
|
42
|
+
}.freeze
|
|
43
|
+
|
|
8
44
|
DEFAULTS = {
|
|
9
45
|
"align" => "center",
|
|
10
46
|
"background-color" => "#414141",
|
|
@@ -5,6 +5,20 @@ module MjmlRb
|
|
|
5
5
|
class Divider < Base
|
|
6
6
|
TAGS = ["mj-divider"].freeze
|
|
7
7
|
|
|
8
|
+
ALLOWED_ATTRIBUTES = {
|
|
9
|
+
"border-color" => "color",
|
|
10
|
+
"border-style" => "string",
|
|
11
|
+
"border-width" => "unit(px)",
|
|
12
|
+
"container-background-color" => "color",
|
|
13
|
+
"padding" => "unit(px,%){1,4}",
|
|
14
|
+
"padding-bottom" => "unit(px,%)",
|
|
15
|
+
"padding-left" => "unit(px,%)",
|
|
16
|
+
"padding-right" => "unit(px,%)",
|
|
17
|
+
"padding-top" => "unit(px,%)",
|
|
18
|
+
"width" => "unit(px,%)",
|
|
19
|
+
"align" => "enum(left,center,right)"
|
|
20
|
+
}.freeze
|
|
21
|
+
|
|
8
22
|
DEFAULTS = {
|
|
9
23
|
"align" => "center",
|
|
10
24
|
"border-color" => "#000000",
|
|
@@ -5,6 +5,38 @@ module MjmlRb
|
|
|
5
5
|
class Image < Base
|
|
6
6
|
TAGS = ["mj-image"].freeze
|
|
7
7
|
|
|
8
|
+
ALLOWED_ATTRIBUTES = {
|
|
9
|
+
"alt" => "string",
|
|
10
|
+
"href" => "string",
|
|
11
|
+
"name" => "string",
|
|
12
|
+
"src" => "string",
|
|
13
|
+
"srcset" => "string",
|
|
14
|
+
"sizes" => "string",
|
|
15
|
+
"title" => "string",
|
|
16
|
+
"rel" => "string",
|
|
17
|
+
"align" => "enum(left,center,right)",
|
|
18
|
+
"border" => "string",
|
|
19
|
+
"border-bottom" => "string",
|
|
20
|
+
"border-left" => "string",
|
|
21
|
+
"border-right" => "string",
|
|
22
|
+
"border-top" => "string",
|
|
23
|
+
"border-radius" => "unit(px,%){1,4}",
|
|
24
|
+
"container-background-color" => "color",
|
|
25
|
+
"fluid-on-mobile" => "boolean",
|
|
26
|
+
"full-width" => "enum(full-width)",
|
|
27
|
+
"padding" => "unit(px,%){1,4}",
|
|
28
|
+
"padding-bottom" => "unit(px,%)",
|
|
29
|
+
"padding-left" => "unit(px,%)",
|
|
30
|
+
"padding-right" => "unit(px,%)",
|
|
31
|
+
"padding-top" => "unit(px,%)",
|
|
32
|
+
"target" => "string",
|
|
33
|
+
"width" => "unit(px)",
|
|
34
|
+
"height" => "unit(px,auto)",
|
|
35
|
+
"max-height" => "unit(px,%)",
|
|
36
|
+
"font-size" => "unit(px)",
|
|
37
|
+
"usemap" => "string"
|
|
38
|
+
}.freeze
|
|
39
|
+
|
|
8
40
|
DEFAULTS = {
|
|
9
41
|
"alt" => "",
|
|
10
42
|
"align" => "center",
|
data/lib/mjml-rb/validator.rb
CHANGED
|
@@ -130,6 +130,10 @@ module MjmlRb
|
|
|
130
130
|
case expected_type
|
|
131
131
|
when "string"
|
|
132
132
|
true
|
|
133
|
+
when "boolean"
|
|
134
|
+
%w[true false].include?(value)
|
|
135
|
+
when "integer"
|
|
136
|
+
value.match?(/\A-?\d+\z/)
|
|
133
137
|
when "color"
|
|
134
138
|
color?(value)
|
|
135
139
|
when /\Aenum\((.+)\)\z/
|
|
@@ -162,7 +166,7 @@ module MjmlRb
|
|
|
162
166
|
return true if value.match?(/\A0(?:\.0+)?\z/)
|
|
163
167
|
|
|
164
168
|
units.any? do |unit|
|
|
165
|
-
value.match?(/\A-?\d+(?:\.\d+)?#{Regexp.escape(unit)}\z/)
|
|
169
|
+
value == unit || value.match?(/\A-?\d+(?:\.\d+)?#{Regexp.escape(unit)}\z/)
|
|
166
170
|
end
|
|
167
171
|
end
|
|
168
172
|
|
data/lib/mjml-rb/version.rb
CHANGED