mjml-rb 0.2.26 → 0.2.27

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: f821f46d065dc6d6f587dab7e8a7617b29cb0806b6fcfdf2315716e1dbcd2ca5
4
- data.tar.gz: 46bab2d4220a372ee0b4116cc8e3592a7a8e8f40736ac2c30a7cc959f640e5b1
3
+ metadata.gz: 211fc22a84a2d44ba110d30cc53e6fc9f6ea9811bb026d85e75c3c461b6da256
4
+ data.tar.gz: 3928ee8b712c2837fe3cca6a69fa0305e9d97561e1878afabcc171f257aeaca5
5
5
  SHA512:
6
- metadata.gz: 0b1925984de0312ff6090c68d4fa70e49cccebfba14c1de94c56e0eece6828deac28e5b32e86f3f49afcaf962797ab696dd5f80ed5852400a4d515b6bea4cdd0
7
- data.tar.gz: 42c8b09f6e014157186153483bd6b7fa77aa141c52cb0aa4a2dffaacf71d216082881a3a4760676b17c1b920740456ec3190cfa95d389c8bdbd35a2f73f2ce8a
6
+ metadata.gz: d4611a4144b4dc634781eb9d325b6c00ba14a6c13c1a9984e650b07ccc7f80061dd389193b936f415909812320bae6fecf392c6ad7a44100f753788d46b989d5
7
+ data.tar.gz: 33182fcdd497ed46f93fed3c48efe84137e85f3b8d619e70a5148d8436711d2d2ae5de21cb4df508c749ee32a9e4960e330e8d51fc0caa433db8e8be41d615f6
@@ -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,37 @@ 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
+ "padding" => "unit(px,%){1,4}",
27
+ "padding-bottom" => "unit(px,%)",
28
+ "padding-left" => "unit(px,%)",
29
+ "padding-right" => "unit(px,%)",
30
+ "padding-top" => "unit(px,%)",
31
+ "target" => "string",
32
+ "width" => "unit(px)",
33
+ "height" => "unit(px,auto)",
34
+ "max-height" => "unit(px,%)",
35
+ "font-size" => "unit(px)",
36
+ "usemap" => "string"
37
+ }.freeze
38
+
8
39
  DEFAULTS = {
9
40
  "alt" => "",
10
41
  "align" => "center",
@@ -130,6 +130,8 @@ module MjmlRb
130
130
  case expected_type
131
131
  when "string"
132
132
  true
133
+ when "boolean"
134
+ %w[true false].include?(value)
133
135
  when "color"
134
136
  color?(value)
135
137
  when /\Aenum\((.+)\)\z/
@@ -162,7 +164,7 @@ module MjmlRb
162
164
  return true if value.match?(/\A0(?:\.0+)?\z/)
163
165
 
164
166
  units.any? do |unit|
165
- value.match?(/\A-?\d+(?:\.\d+)?#{Regexp.escape(unit)}\z/)
167
+ value == unit || value.match?(/\A-?\d+(?:\.\d+)?#{Regexp.escape(unit)}\z/)
166
168
  end
167
169
  end
168
170
 
@@ -1,3 +1,3 @@
1
1
  module MjmlRb
2
- VERSION = "0.2.26".freeze
2
+ VERSION = "0.2.27".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.26
4
+ version: 0.2.27
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrei Andriichuk