mjml-rb 0.3.4 → 0.3.5
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/carousel_image.rb +1 -1
- data/lib/mjml-rb/components/social.rb +6 -6
- data/lib/mjml-rb/renderer.rb +5 -8
- 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: 5eb69fb3fdaed9855a8fa7f791aecf11332bc08dbf5415237e792b48debaf00a
|
|
4
|
+
data.tar.gz: 15926b8c8af6b74f69ce4d579909fc9059a56b07cdd9fbe6d6007a375caf38c4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ea326cf19e80f7fb403e8d2fa32b5ec8d7383538cde6d8ca2062e01ffbd3ffd8ffa0db116215dd16f70134ade1b759458e8c35ca46ba3224b56ec5f7810757d3
|
|
7
|
+
data.tar.gz: 1c46e6d13a3c0d7c77313f5e2c8a8cbf3bf3a6cc250dc09e08f806a220c2b8fb1dc276f99c5db22f3210b928f01769893265d95d73d6ccb32ea509da9d507404
|
|
@@ -150,7 +150,7 @@ module MjmlRb
|
|
|
150
150
|
ordered_keys = %w[title src alt style width border]
|
|
151
151
|
rendered = ordered_keys.filter_map do |key|
|
|
152
152
|
next unless attrs.key?(key)
|
|
153
|
-
next if
|
|
153
|
+
next if attrs[key].nil?
|
|
154
154
|
|
|
155
155
|
%(#{key}="#{escape_attr(attrs[key].to_s)}")
|
|
156
156
|
end
|
|
@@ -360,15 +360,15 @@ module MjmlRb
|
|
|
360
360
|
%(<tr#{tr_class}>#{cells}</tr>)
|
|
361
361
|
end
|
|
362
362
|
|
|
363
|
-
# Build an <img> tag
|
|
363
|
+
# Build an <img> tag — nil attributes are omitted, empty strings preserved.
|
|
364
364
|
def build_img_tag(alt:, title:, src:, style:, width:, sizes:, srcset:)
|
|
365
365
|
parts = [%( alt="#{escape_attr(alt.to_s)}")]
|
|
366
|
-
parts << %( title="#{escape_attr(title)}") unless title.nil?
|
|
367
|
-
parts << %( src="#{escape_attr(src)}") unless src.nil?
|
|
366
|
+
parts << %( title="#{escape_attr(title)}") unless title.nil?
|
|
367
|
+
parts << %( src="#{escape_attr(src)}") unless src.nil?
|
|
368
368
|
parts << %( style="#{style}") unless style.nil? || style.empty?
|
|
369
|
-
parts << %( width="#{escape_attr(width)}") unless width.nil?
|
|
370
|
-
parts << %( sizes="#{escape_attr(sizes)}") unless sizes.nil?
|
|
371
|
-
parts << %( srcset="#{escape_attr(srcset)}") unless srcset.nil?
|
|
369
|
+
parts << %( width="#{escape_attr(width)}") unless width.nil?
|
|
370
|
+
parts << %( sizes="#{escape_attr(sizes)}") unless sizes.nil?
|
|
371
|
+
parts << %( srcset="#{escape_attr(srcset)}") unless srcset.nil?
|
|
372
372
|
"<img#{parts.join} />"
|
|
373
373
|
end
|
|
374
374
|
end
|
data/lib/mjml-rb/renderer.rb
CHANGED
|
@@ -830,16 +830,13 @@ module MjmlRb
|
|
|
830
830
|
CGI.escapeHTML(value.to_s)
|
|
831
831
|
end
|
|
832
832
|
|
|
833
|
-
#
|
|
834
|
-
# `
|
|
835
|
-
#
|
|
836
|
-
KEEP_WHEN_EMPTY = Set.new(%w[alt]).freeze
|
|
837
|
-
|
|
833
|
+
# Match npm MJML behaviour: omit only nil/undefined attributes.
|
|
834
|
+
# lodash `omitBy(attributes, isNil)` keeps empty strings, so we do the same.
|
|
835
|
+
# This preserves semantically meaningful empty values like `alt=""`.
|
|
838
836
|
def html_attrs(hash)
|
|
839
837
|
attrs = hash.each_with_object([]) do |(key, value), memo|
|
|
840
|
-
if value.nil?
|
|
841
|
-
|
|
842
|
-
end
|
|
838
|
+
next if value.nil?
|
|
839
|
+
|
|
843
840
|
memo << %(#{key}="#{escape_attr(value)}")
|
|
844
841
|
end
|
|
845
842
|
return "" if attrs.empty?
|
data/lib/mjml-rb/version.rb
CHANGED