mjml-rb 0.3.5 → 0.3.7

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: 414eb19865bc6fe6432e0ed0576001365e2c7fcc9e6133005bf4f4cefc89f35b
4
+ data.tar.gz: 420df02142daf9807af8fa96d2ad0ca5ca13f68ffa737781c4c38a85c176d29b
5
5
  SHA512:
6
- metadata.gz: ea326cf19e80f7fb403e8d2fa32b5ec8d7383538cde6d8ca2062e01ffbd3ffd8ffa0db116215dd16f70134ade1b759458e8c35ca46ba3224b56ec5f7810757d3
7
- data.tar.gz: 1c46e6d13a3c0d7c77313f5e2c8a8cbf3bf3a6cc250dc09e08f806a220c2b8fb1dc276f99c5db22f3210b928f01769893265d95d73d6ccb32ea509da9d507404
6
+ metadata.gz: 77e7e40b344e0560b75ec58d1a5e0364f2b8c148f985cba18c77cc678114381416157709db251ef6e3762886a286b2da2d8bb7e38cbfaed07006ed9161c1d0fe
7
+ data.tar.gz: 2511e7880dcb3dccb36dd97228f1e49b9384b0e2f31ed0c51b91db1287d56bd9c5a40f81637dc30cfb783fbd743129523fffcb93e19cab220227f3e6cd836745
data/README.md CHANGED
@@ -1,16 +1,13 @@
1
1
  # MJML Ruby Implementation
2
2
 
3
- > **⚠️ EXPERIMENTAL USE AT YOUR OWN RISK**
4
- >
5
- > This is an **unofficial, experimental** Ruby port of the MJML email framework.
6
- > It is **not affiliated with or endorsed by the MJML team**.
7
- > The output HTML may differ from the reference `mjml` npm package in subtle ways,
8
- > and not all components or attributes are fully implemented yet.
9
- > **Do not use in production without thorough testing of every template against
10
- > the official npm renderer.** API and output format may change without notice.
11
- > This is a **fully open source project**, and help is welcome:
12
- > feedback, bug reports, test cases, optimizations, proposals, and pull requests.
13
- > No warranty of any kind is provided.
3
+ > **Note:** This is an unofficial Ruby port of the MJML email framework,
4
+ > not affiliated with or endorsed by the MJML team.
5
+ > All 22 MJML v4 components are implemented and tested against npm MJML v4.18.0.
6
+ > Output may differ from the npm renderer in cosmetic ways (whitespace, attribute ordering)
7
+ > but renders identically across email clients.
8
+ > We recommend testing your templates when migrating from the npm renderer.
9
+ > This is a **fully open source project** feedback, bug reports, test cases,
10
+ > and pull requests are welcome!
14
11
 
15
12
  This gem provides a Ruby-first implementation of the main MJML tooling:
16
13
 
@@ -20,6 +17,8 @@ This gem provides a Ruby-first implementation of the main MJML tooling:
20
17
  - pure Ruby parser, AST, validator, and renderer
21
18
  - no Node.js runtime and no shelling out to the official npm renderer
22
19
 
20
+ Remaining parity work is tracked in [npm ↔ Ruby Parity Audit](docs/PARITY_AUDIT.md).
21
+
23
22
  ## Compatibility
24
23
 
25
24
  This project targets **MJML v4 only**.
@@ -205,5 +204,3 @@ If you want the full internal walkthrough, see [docs/ARCHITECTURE.md](docs/ARCHI
205
204
  > plain Ruby project and render MJML templates the same way you render ERB — no
206
205
  > extra runtime, no
207
206
  > `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.7".freeze
3
3
  end
data/mjml-rb.gemspec CHANGED
@@ -18,6 +18,6 @@ Gem::Specification.new do |spec|
18
18
  spec.bindir = "bin"
19
19
  spec.executables = ["mjml"]
20
20
  spec.require_paths = ["lib"]
21
- spec.add_dependency "nokogiri"
22
- spec.add_dependency "rexml"
21
+ spec.add_dependency "nokogiri", ">= 1.13"
22
+ spec.add_dependency "rexml", ">= 3.2.5"
23
23
  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.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrei Andriichuk
@@ -15,28 +15,28 @@ dependencies:
15
15
  requirements:
16
16
  - - ">="
17
17
  - !ruby/object:Gem::Version
18
- version: '0'
18
+ version: '1.13'
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - ">="
24
24
  - !ruby/object:Gem::Version
25
- version: '0'
25
+ version: '1.13'
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: rexml
28
28
  requirement: !ruby/object:Gem::Requirement
29
29
  requirements:
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
- version: '0'
32
+ version: 3.2.5
33
33
  type: :runtime
34
34
  prerelease: false
35
35
  version_requirements: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - ">="
38
38
  - !ruby/object:Gem::Version
39
- version: '0'
39
+ version: 3.2.5
40
40
  description: Ruby-first MJML compiler API and CLI with compatibility-focused behavior.
41
41
  email:
42
42
  - andreiandriichuk@gmail.com