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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5eb69fb3fdaed9855a8fa7f791aecf11332bc08dbf5415237e792b48debaf00a
4
- data.tar.gz: 15926b8c8af6b74f69ce4d579909fc9059a56b07cdd9fbe6d6007a375caf38c4
3
+ metadata.gz: 8416ab91e9a9d1c4addbbed2368136715d3726b5524e3cce2f27865c5522b6f2
4
+ data.tar.gz: 576c18c2307ca32b30012e2e91450b2888e1f6cf13c9398bd0c7da7ef616bb7d
5
5
  SHA512:
6
- metadata.gz: ea326cf19e80f7fb403e8d2fa32b5ec8d7383538cde6d8ca2062e01ffbd3ffd8ffa0db116215dd16f70134ade1b759458e8c35ca46ba3224b56ec5f7810757d3
7
- data.tar.gz: 1c46e6d13a3c0d7c77313f5e2c8a8cbf3bf3a6cc250dc09e08f806a220c2b8fb1dc276f99c5db22f3210b928f01769893265d95d73d6ccb32ea509da9d507404
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
- #{build_img_tag(image_attrs)}
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 = build_img_tag(img_attrs)
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
- # alt must always be rendered (even as alt=""), so build img tag manually
308
- img_tag = build_img_tag(
309
- alt: alt_val, title: title_val, src: src,
310
- style: img_style, width: icon_width, sizes: sizes_attr, srcset: srcset
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
@@ -1,3 +1,3 @@
1
1
  module MjmlRb
2
- VERSION = "0.3.5".freeze
2
+ VERSION = "0.3.6".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.3.5
4
+ version: 0.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrei Andriichuk