mjml-rb 0.2.10 → 0.2.12
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/button.rb +1 -1
- data/lib/mjml-rb/renderer.rb +34 -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: b877cf70c778c4916d93167e650dd7238bc0a50044055b4784681cb9b72a2488
|
|
4
|
+
data.tar.gz: 642a476a1142ae386d8f6af1b05b555e46638e69cf83dfabbd8247c2c09d8f7d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9da675856ef3de4e27f421c37a5a54f0b89065a13b3613000439d97493959269269d77d46416e7edb4550516b88a8b645c8847328595baa408eaac9045eaea5a
|
|
7
|
+
data.tar.gz: e14ef3402314fc2fbbb3b292945c5d7116340e5a14f8fe78d3f171054a25acdc43227396a00d6a12950e0492eefcfb04c7ea896618a9112f16a501ebe80b8921
|
|
@@ -101,7 +101,7 @@ module MjmlRb
|
|
|
101
101
|
)
|
|
102
102
|
link_attrs = { "style" => link_style }
|
|
103
103
|
if tag == "a"
|
|
104
|
-
link_attrs["href"] =
|
|
104
|
+
link_attrs["href"] = href
|
|
105
105
|
link_attrs["name"] = a["name"]
|
|
106
106
|
link_attrs["rel"] = a["rel"]
|
|
107
107
|
link_attrs["title"] = a["title"]
|
data/lib/mjml-rb/renderer.rb
CHANGED
|
@@ -367,9 +367,43 @@ module MjmlRb
|
|
|
367
367
|
declarations.each do |property, value|
|
|
368
368
|
existing[property] = value
|
|
369
369
|
end
|
|
370
|
+
normalize_background_fallbacks!(node, existing)
|
|
370
371
|
node["style"] = existing.map { |property, value| "#{property}: #{value}" }.join("; ")
|
|
371
372
|
end
|
|
372
373
|
|
|
374
|
+
def normalize_background_fallbacks!(node, declarations)
|
|
375
|
+
background_color = declarations["background-color"]
|
|
376
|
+
return if background_color.nil? || background_color.empty?
|
|
377
|
+
|
|
378
|
+
if syncable_background?(declarations["background"])
|
|
379
|
+
declarations["background"] = background_color
|
|
380
|
+
end
|
|
381
|
+
|
|
382
|
+
return unless node.name == "td"
|
|
383
|
+
return unless node["bgcolor"]
|
|
384
|
+
return if %w[none transparent].include?(background_color.downcase)
|
|
385
|
+
|
|
386
|
+
node["bgcolor"] = background_color
|
|
387
|
+
end
|
|
388
|
+
|
|
389
|
+
def syncable_background?(value)
|
|
390
|
+
return true if value.nil? || value.empty?
|
|
391
|
+
|
|
392
|
+
normalized = value.downcase
|
|
393
|
+
!normalized.include?("url(") &&
|
|
394
|
+
!normalized.include?("gradient(") &&
|
|
395
|
+
!normalized.include?("/") &&
|
|
396
|
+
!normalized.include?(" no-repeat") &&
|
|
397
|
+
!normalized.include?(" repeat") &&
|
|
398
|
+
!normalized.include?(" fixed") &&
|
|
399
|
+
!normalized.include?(" scroll") &&
|
|
400
|
+
!normalized.include?(" center") &&
|
|
401
|
+
!normalized.include?(" top") &&
|
|
402
|
+
!normalized.include?(" bottom") &&
|
|
403
|
+
!normalized.include?(" left") &&
|
|
404
|
+
!normalized.include?(" right")
|
|
405
|
+
end
|
|
406
|
+
|
|
373
407
|
def append_component_head_styles(document, context)
|
|
374
408
|
component_registry.each_value.uniq.each do |component|
|
|
375
409
|
next unless component.respond_to?(:head_style)
|
data/lib/mjml-rb/version.rb
CHANGED