mjml-rb 0.3.5 → 0.3.6
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/README.md +2 -2
- data/lib/mjml-rb/components/carousel_image.rb +2 -13
- data/lib/mjml-rb/components/social.rb +10 -16
- 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: 8416ab91e9a9d1c4addbbed2368136715d3726b5524e3cce2f27865c5522b6f2
|
|
4
|
+
data.tar.gz: 576c18c2307ca32b30012e2e91450b2888e1f6cf13c9398bd0c7da7ef616bb7d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c3ed81729d5550ae8611f0b4fd17545373b8c4041fc286f655c6c975be42182aab441a8c11d07e7a15578a55a6d83849e33e4507f99f45d925ea81212e04607c
|
|
7
|
+
data.tar.gz: e407a972325006108bce56759035dfa0b00f93d1917c162d04c2c2ad3d299c0bb03f15a36d3f49c6a26d3d3e2ee058f45fbf29c96a016034c85372af87db4404
|
data/README.md
CHANGED
|
@@ -20,6 +20,8 @@ This gem provides a Ruby-first implementation of the main MJML tooling:
|
|
|
20
20
|
- pure Ruby parser, AST, validator, and renderer
|
|
21
21
|
- no Node.js runtime and no shelling out to the official npm renderer
|
|
22
22
|
|
|
23
|
+
Remaining parity work is tracked in [npm ↔ Ruby Parity Audit](docs/PARITY_AUDIT.md).
|
|
24
|
+
|
|
23
25
|
## Compatibility
|
|
24
26
|
|
|
25
27
|
This project targets **MJML v4 only**.
|
|
@@ -205,5 +207,3 @@ If you want the full internal walkthrough, see [docs/ARCHITECTURE.md](docs/ARCHI
|
|
|
205
207
|
> plain Ruby project and render MJML templates the same way you render ERB — no
|
|
206
208
|
> extra runtime, no
|
|
207
209
|
> `package.json`, no `node_modules`.
|
|
208
|
-
|
|
209
|
-
Remaining parity work is tracked in [npm ↔ Ruby Parity Audit](docs/PARITY_AUDIT.md).
|
|
@@ -92,7 +92,7 @@ module MjmlRb
|
|
|
92
92
|
<<~HTML.chomp
|
|
93
93
|
<a#{html_attrs(link_attrs)}>
|
|
94
94
|
<label#{html_attrs(label_attrs)}>
|
|
95
|
-
#{
|
|
95
|
+
<img#{html_attrs(image_attrs)} />
|
|
96
96
|
</label>
|
|
97
97
|
</a>
|
|
98
98
|
HTML
|
|
@@ -117,7 +117,7 @@ module MjmlRb
|
|
|
117
117
|
"width" => container_width.to_i.to_s,
|
|
118
118
|
"border" => "0"
|
|
119
119
|
}
|
|
120
|
-
image_tag =
|
|
120
|
+
image_tag = "<img#{html_attrs(img_attrs)} />"
|
|
121
121
|
|
|
122
122
|
content = if a["href"]
|
|
123
123
|
link_attrs = {
|
|
@@ -146,17 +146,6 @@ module MjmlRb
|
|
|
146
146
|
classes.split(/\s+/).map { |klass| "#{klass}-#{suffix}" }.join(" ")
|
|
147
147
|
end
|
|
148
148
|
|
|
149
|
-
def build_img_tag(attrs)
|
|
150
|
-
ordered_keys = %w[title src alt style width border]
|
|
151
|
-
rendered = ordered_keys.filter_map do |key|
|
|
152
|
-
next unless attrs.key?(key)
|
|
153
|
-
next if attrs[key].nil?
|
|
154
|
-
|
|
155
|
-
%(#{key}="#{escape_attr(attrs[key].to_s)}")
|
|
156
|
-
end
|
|
157
|
-
|
|
158
|
-
"<img #{rendered.join(' ')} />"
|
|
159
|
-
end
|
|
160
149
|
end
|
|
161
150
|
end
|
|
162
151
|
end
|
|
@@ -304,11 +304,16 @@ module MjmlRb
|
|
|
304
304
|
"display" => "block"
|
|
305
305
|
)
|
|
306
306
|
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
307
|
+
img_attrs = {
|
|
308
|
+
"alt" => alt_val,
|
|
309
|
+
"title" => title_val,
|
|
310
|
+
"src" => src,
|
|
311
|
+
"style" => img_style.empty? ? nil : img_style,
|
|
312
|
+
"width" => icon_width,
|
|
313
|
+
"sizes" => sizes_attr,
|
|
314
|
+
"srcset" => srcset
|
|
315
|
+
}
|
|
316
|
+
img_tag = "<img#{html_attrs(img_attrs)} />"
|
|
312
317
|
|
|
313
318
|
if has_link
|
|
314
319
|
link_attrs_str = html_attrs({ "href" => final_href, "rel" => rel_val, "target" => target_val })
|
|
@@ -360,17 +365,6 @@ module MjmlRb
|
|
|
360
365
|
%(<tr#{tr_class}>#{cells}</tr>)
|
|
361
366
|
end
|
|
362
367
|
|
|
363
|
-
# Build an <img> tag — nil attributes are omitted, empty strings preserved.
|
|
364
|
-
def build_img_tag(alt:, title:, src:, style:, width:, sizes:, srcset:)
|
|
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?
|
|
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?
|
|
372
|
-
"<img#{parts.join} />"
|
|
373
|
-
end
|
|
374
368
|
end
|
|
375
369
|
end
|
|
376
370
|
end
|
data/lib/mjml-rb/version.rb
CHANGED