mjml-rails 4.15.1 → 4.16.0

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: 9c6559e7522a96885f084a543108e00fc80bf778dd371edbf6a67ffb20c8269a
4
- data.tar.gz: e14f43e0de4ad7524c1774784552299fd9689b1643b9504e73f44bed92677c2e
3
+ metadata.gz: 2765f5756d63843512d96e8c0dca3d5ae41c132e2e527ffd1d161e963ff39e8c
4
+ data.tar.gz: d7c19dae4feafb3593e4f478463897f1310a0950414811fef87de94323ec8e4d
5
5
  SHA512:
6
- metadata.gz: fe6820680ae3e42c303ac19d687b2fd01b7c36eb16f9deb590a34e3fe0eb6fd55774f09f95514a46239d233c2209b73247f0e8c577a2c3902e509596c0f8e7ac
7
- data.tar.gz: 79ef029fc1a7cecdc35bb3e7681edb865968e5263e110bf7a0b1a87316a6d403e60d6e8383936fda29d6494e118cbf64b8756599933291b6711a63de08fd0548
6
+ metadata.gz: 5d8f725b93ec25cd3102309b453771157971bdf976d4f3f641ef51a78c90f678d518db51119110c1a5df53882e30814a16fcaf8ecef7eae07f59a05700df91ce
7
+ data.tar.gz: 36afdf274545cc6a8222ea86a03d9c020a7b248f8761454e73d4f68d515dfaeb665474a270e80f6ef4822e90d3a8b02275065d96f35fa75b5870cb0e039193c5
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/mjml/handler.rb CHANGED
@@ -17,7 +17,7 @@ module Mjml
17
17
  compiled_source = compile_source(source, template)
18
18
 
19
19
  parser_class = Mjml.use_mrml ? 'MrmlParser' : 'Parser'
20
- template_path = template.virtual_path
20
+ template_path = template.respond_to?(:virtual_path) ? template.virtual_path : template.identifier
21
21
  # Per MJML v4 syntax documentation[0] valid/render'able document MUST start with <mjml> root tag
22
22
  # If we get here and template source doesn't start with one it means
23
23
  # that we are rendering partial named according to legacy naming convention (partials ending with '.mjml')
data/lib/mjml/version.rb CHANGED
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Mjml
4
4
  # Version number no longer matches MJML.io version
5
- VERSION = '4.15.1'
5
+ VERSION = '4.16.0'
6
6
  end
@@ -0,0 +1,83 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'test_helper'
4
+
5
+ class HandlerTest < ActiveSupport::TestCase
6
+ def setup
7
+ @handler = Mjml::Handler.new
8
+ end
9
+
10
+ test 'uses virtual_path when available' do
11
+ template = mock
12
+ template.stubs(:virtual_path).returns('/path/to/template')
13
+ template.stubs(:respond_to?).with(:virtual_path).returns(true)
14
+
15
+ compiled_source = '<mjml><mj-body><mj-text>Hello</mj-text></mj-body></mjml>'
16
+ @handler.stubs(:compile_source).returns(compiled_source)
17
+
18
+ result = @handler.call(template)
19
+
20
+ assert_includes result, '/path/to/template'
21
+ end
22
+
23
+ test 'falls back to identifier when virtual_path is not available' do
24
+ # Simulate ViewComponent::Template::DataWithSource behavior
25
+ template = mock
26
+ template.stubs(:identifier).returns('/path/to/component/template')
27
+ template.stubs(:respond_to?).with(:virtual_path).returns(false)
28
+
29
+ compiled_source = '<mjml><mj-body><mj-text>Hello</mj-text></mj-body></mjml>'
30
+ @handler.stubs(:compile_source).returns(compiled_source)
31
+
32
+ result = @handler.call(template)
33
+
34
+ assert_includes result, '/path/to/component/template'
35
+ end
36
+
37
+ test 'handles partials without mjml root tag' do
38
+ template = mock
39
+ template.stubs(:virtual_path).returns('/path/to/partial')
40
+ template.stubs(:respond_to?).with(:virtual_path).returns(true)
41
+
42
+ # Partial without <mjml> root tag
43
+ compiled_source = '<mj-text>This is a partial</mj-text>'
44
+ @handler.stubs(:compile_source).returns(compiled_source)
45
+
46
+ result = @handler.call(template)
47
+
48
+ # Should return the compiled source as-is for partials
49
+ assert_equal compiled_source, result
50
+ end
51
+
52
+ test 'processes full MJML documents' do
53
+ template = mock
54
+ template.stubs(:virtual_path).returns('/path/to/template')
55
+ template.stubs(:respond_to?).with(:virtual_path).returns(true)
56
+
57
+ compiled_source = '<mjml><mj-body><mj-text>Full document</mj-text></mj-body></mjml>'
58
+ @handler.stubs(:compile_source).returns(compiled_source)
59
+
60
+ result = @handler.call(template)
61
+
62
+ # Should return parser invocation for full MJML documents
63
+ assert_includes result, "Mjml::Parser.new('/path/to/template'"
64
+ assert_includes result, '.render.html_safe'
65
+ end
66
+
67
+ test 'uses MrmlParser when use_mrml is true' do
68
+ Mjml.stubs(:use_mrml).returns(true)
69
+
70
+ template = mock
71
+ template.stubs(:virtual_path).returns('/path/to/template')
72
+ template.stubs(:respond_to?).with(:virtual_path).returns(true)
73
+
74
+ compiled_source = '<mjml><mj-body><mj-text>Full document</mj-text></mj-body></mjml>'
75
+ @handler.stubs(:compile_source).returns(compiled_source)
76
+
77
+ result = @handler.call(template)
78
+
79
+ assert_includes result, "Mjml::MrmlParser.new('/path/to/template'"
80
+ ensure
81
+ Mjml.unstub(:use_mrml)
82
+ end
83
+ end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mjml-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.15.1
4
+ version: 4.16.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simon Loffler
@@ -35,7 +35,7 @@ cert_chain:
35
35
  Qqk2dn/fFE9vdcl9OaOw2Zizne/1VFL/jkzXLqnLgbKD/q129mVCBgw2CKYnQfMN
36
36
  4RwBjPyqnMxWnSq6Ycn7HdFEkgyf2cAxFfH5QtDsjEuca+/LAJMeAQ==
37
37
  -----END CERTIFICATE-----
38
- date: 2025-04-07 00:00:00.000000000 Z
38
+ date: 1980-01-02 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: byebug
@@ -171,6 +171,7 @@ files:
171
171
  - lib/mjml/railtie.rb
172
172
  - lib/mjml/version.rb
173
173
  - test/generator_test.rb
174
+ - test/handler_test.rb
174
175
  - test/mjml_test.rb
175
176
  - test/mrml_parser_test.rb
176
177
  - test/parser_test.rb
@@ -194,11 +195,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
194
195
  - !ruby/object:Gem::Version
195
196
  version: '0'
196
197
  requirements: []
197
- rubygems_version: 3.6.2
198
+ rubygems_version: 3.6.9
198
199
  specification_version: 4
199
200
  summary: MJML + ERb templates
200
201
  test_files:
201
202
  - test/generator_test.rb
203
+ - test/handler_test.rb
202
204
  - test/mjml_test.rb
203
205
  - test/mrml_parser_test.rb
204
206
  - test/parser_test.rb
metadata.gz.sig CHANGED
Binary file