mjml-rails 4.4.2 → 4.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a8610d3313ee8297b7ac411aa8f23b8c99a85cf41940db1798529d91193fb37d
4
- data.tar.gz: c5099915099d3aeb6e050bf44b3cb81b8fe759686a06b85d61a197e65b7b4dfb
3
+ metadata.gz: 7b9582e0d35041cd78aa95808af7d2808ce467eb1b70eb511b57f39679b661af
4
+ data.tar.gz: 402a1cf82168f58d8abde20ad280473e897eb0d0489d88281c72d52e830c71c8
5
5
  SHA512:
6
- metadata.gz: 717f6819381d9f925ce597f05288cfc6f3c07417e353de40561de9ddffc6ac48331e4877ed775818b7b3dbd3836c27e2347bafcbcc9c0247b467565e944911ab
7
- data.tar.gz: ec6662022e6ed5f5e8b6732d61fa766de5af32dd57fcd43c508576bcb7f594b1f413b17452532fa4e7ee94b46d1c90427bb90e3cff1425ae39c05d46c38f371e
6
+ metadata.gz: 31edb6ed2fbfaa8e1888a97e6a07334e0551b67ab1ed66153445be516ca2f916b76e4cf0d378915d7ee3cb5082cdd307570bfc1191760bb19243472e4758b757
7
+ data.tar.gz: 85be7ae9d1be8adeac4020cfed26e9a30fa917bb7c051b88b3c9c14a1a204b9ad64d37c3a5920d72a9593fc6389fd71cad59ae0baf3b0bdc5f9cb7892c8501c6
checksums.yaml.gz.sig CHANGED
Binary file
data/README.md CHANGED
@@ -1,15 +1,15 @@
1
1
  # MJML-Rails
2
2
 
3
- [![Build Status](https://api.travis-ci.org/sighmon/mjml-rails.svg?branch=master)](http://travis-ci.org/sighmon/mjml-rails) [![Gem Version](https://badge.fury.io/rb/mjml-rails.svg)](https://badge.fury.io/rb/mjml-rails)
3
+ [![Build Status](https://github.com/sighmon/mjml-rails/workflows/test/badge.svg?branch=master)](https://github.com/sighmon/mjml-rails/actions?query=workflow%3Atest+branch%3Amaster) [![Gem Version](https://badge.fury.io/rb/mjml-rails.svg)](https://badge.fury.io/rb/mjml-rails)
4
4
 
5
- **MJML-Rails** allows you to render HTML e-mails from an [MJML](https://mjml.io) template.
5
+ **MJML-Rails** allows you to render HTML emails from an [MJML](https://mjml.io) template.
6
6
 
7
7
  **Note**: As of MJML 4.3.0 you can no longer use `<mj-text>` directly inside an `<mj-body>`, wrap it in `<mj-section><mj-column>`.
8
8
 
9
9
  An example template might look like:
10
10
 
11
11
  ```erb
12
- <!-- ./app/views/user_mailer/email.html.mjml -->
12
+ <!-- ./app/views/user_mailer/user_signup_confirmation.mjml -->
13
13
  <mjml>
14
14
  <mj-head>
15
15
  <mj-preview>Hello World</mj-preview>
@@ -18,7 +18,7 @@ An example template might look like:
18
18
  <mj-section>
19
19
  <mj-column>
20
20
  <mj-text>Hello World</mj-text>
21
- <%= render partial: "info" %>
21
+ <%= render partial: "info", formats: [:html] %>
22
22
  </mj-column>
23
23
  </mj-section>
24
24
  </mj-body>
@@ -80,49 +80,65 @@ MJML-Rails falls back to a global installation of MJML but it is strongly recomm
80
80
 
81
81
  You'll need at least Node.js version 6 for MJML to function properly.
82
82
 
83
- If you're using ```:haml``` or any other Rails template language, create an initializer to set it up:
83
+ ## Configuration
84
84
 
85
- ```ruby
86
- # config/initializers/mjml.rb
87
- Mjml.setup do |config|
88
- config.template_language = :erb # :erb (default), :slim, :haml, or any other you are using
89
- end
90
- ```
85
+ MJML-Rails has the following settings with defaults:
86
+
87
+ - `template_language: :erb`
88
+
89
+ ERB can be used inside MJML templates by default. Possible values are all template languages that you have installed, e.g. `:haml` or `:slim`.
90
+
91
+ **Note:** If you’re using Haml/Slim layouts, please don’t put `<mjml>` in comments in your partial. Read more at [#34](https://github.com/sighmon/mjml-rails/issues/34).
92
+
93
+ - `raise_render_exception: true`
94
+
95
+ Exceptions will be raised and passed to your application by default.
96
+
97
+ Beware that setting it to `false` leads to an empty html email when an exception is raised, so only set this to `false` if you do not rely on html (e.g. you have a text fallback for your emails).
98
+
99
+ - `minify: false`
100
+
101
+ - `beautify: true`
102
+
103
+ - `validation_level: "strict"`
91
104
 
92
- **Note:** If you’re using Haml/Slim layouts, please don’t put `<mjml>` in comments in your partial. Read more: [#34](https://github.com/sighmon/mjml-rails/issues/34).
105
+ MJML-Rails will raise an exception on any template error by default.
106
+
107
+ If set to `soft`, MJML will render invalid templates and ignore invalid parts. This means in case of an invalid template those invalid parts will be missing from the output.
108
+
109
+ See [MJML validation documentation](https://github.com/mjmlio/mjml/tree/master/packages/mjml-validator#validating-mjml) for all possible values.
110
+
111
+ - `mjml_binary: nil`
112
+
113
+ This can be used to specify the path to a custom MJML binary if it is not detected automatically (shouldn't be needed).
114
+
115
+ - `mjml_binary_version_support: "4."`
116
+
117
+ MJML-Rails checks the version of the MJML binary and fails if it does not start with this version, e.g. if an old version is installed by accident.
93
118
 
94
- If there are configurations you'd like change:
95
- - render errors: defaults to `true` (errors raised)
96
- - minify: defaults to `false` (not minified)
97
- - beautify: defaults to `true` (beautified)
98
- - validation_level: defaults to `soft` (MJML syntax validation)
99
119
 
100
120
  ```ruby
101
121
  # config/initializers/mjml.rb
102
122
  Mjml.setup do |config|
103
- # set to `false` to ignore errors silently
104
- config.raise_render_exception = true
123
+ # Use :haml as a template language
124
+ config.template_language = :haml
125
+
126
+ # Ignore errors silently
127
+ config.raise_render_exception = false
105
128
 
106
- # optimize the size of your email
129
+ # Optimize the size of your emails
107
130
  config.beautify = false
108
131
  config.minify = true
109
- config.validation_level = "strict"
110
- end
111
- ```
112
132
 
113
- If you’d like to specify a different MJML binary to run other than `4.`:
133
+ # Render MJML templates with errors
134
+ config.validation_level = "soft"
114
135
 
115
- ```ruby
116
- # config/initializers/mjml.rb
117
- Mjml.setup do |config|
136
+ # Use custom MJML binary with custom version
137
+ config.mjml_binary = "/path/to/custom/mjml"
118
138
  config.mjml_binary_version_supported = "3.3.5"
119
139
  end
120
- # If you set a different MJML binary version, you need to re-discover the binary
121
- Mjml::BIN = Mjml.discover_mjml_bin
122
140
  ```
123
141
 
124
- **Note:** If you set a different MJML binary you’ll see warnings in your logs of `already initialized constant Mjml::BIN`. Read more: [#39](https://github.com/sighmon/mjml-rails/issues/39#issuecomment-429151908)
125
-
126
142
  ### MJML v3.x & v4.x support
127
143
 
128
144
  Version 4.x of this gem brings support for MJML 4.x
@@ -1,9 +1,11 @@
1
- require "rails/generators/erb/mailer/mailer_generator"
1
+ # frozen_string_literal: true
2
+
3
+ require 'rails/generators/erb/mailer/mailer_generator'
2
4
 
3
5
  module Mjml
4
6
  module Generators
5
7
  class MailerGenerator < Erb::Generators::MailerGenerator
6
- source_root File.expand_path("../templates", __FILE__)
8
+ source_root File.expand_path('templates', __dir__)
7
9
 
8
10
  private
9
11
 
@@ -26,8 +28,8 @@ module Mjml
26
28
  def filename_with_extensions(name, file_format = format)
27
29
  # Due to MJML single-pass processing nature
28
30
  # layout files MUST have .mjml extension, but views/templates cannot
29
- is_layout_file = name.in?([:layout, "mailer"])
30
- [name, file_format, is_layout_file ? handler : view_handler].compact.join(".")
31
+ is_layout_file = name.in?([:layout, 'mailer'])
32
+ [name, file_format, is_layout_file ? handler : view_handler].compact.join('.')
31
33
  end
32
34
  end
33
35
  end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'action_view'
4
+ require 'action_view/template'
5
+ require 'rails/version'
6
+
7
+ module Mjml
8
+ class Handler
9
+ def template_handler
10
+ @template_handler ||= ActionView::Template.registered_template_handler(Mjml.template_language)
11
+ end
12
+
13
+ # Optional second source parameter to make it work with Rails >= 6:
14
+ # Beginning with Rails 6 template handlers get the source of the template as the second
15
+ # parameter.
16
+ def call(template, source = nil)
17
+ compiled_source = compile_source(source, template)
18
+
19
+ # Per MJML v4 syntax documentation[0] valid/render'able document MUST start with <mjml> root tag
20
+ # If we get here and template source doesn't start with one it means
21
+ # that we are rendering partial named according to legacy naming convention (partials ending with '.mjml')
22
+ # Therefore we skip MJML processing and return raw compiled source. It will be processed
23
+ # by MJML library when top-level layout/template is rendered
24
+ #
25
+ # [0] - https://github.com/mjmlio/mjml/blob/master/doc/components_1.md#mjml
26
+ if /<mjml.*?>/i.match?(compiled_source)
27
+ "Mjml::Parser.new(begin;#{compiled_source};end).render.html_safe"
28
+ else
29
+ compiled_source
30
+ end
31
+ end
32
+
33
+ private
34
+
35
+ def compile_source(source, template)
36
+ if Rails::VERSION::MAJOR >= 6
37
+ template_handler.call(template, source)
38
+ else
39
+ template_handler.call(template)
40
+ end
41
+ end
42
+ end
43
+ end
data/lib/mjml/parser.rb CHANGED
@@ -1,4 +1,4 @@
1
- require 'open3'
1
+ # frozen_string_literal: true
2
2
 
3
3
  module Mjml
4
4
  class Parser
@@ -9,8 +9,9 @@ module Mjml
9
9
  # Create new parser
10
10
  #
11
11
  # @param input [String] The string to transform in html
12
- def initialize input
13
- raise Mjml.mjml_binary_error_string unless mjml_bin
12
+ def initialize(input)
13
+ raise Mjml.mjml_binary_error_string unless Mjml.valid_mjml_binary
14
+
14
15
  @input = input
15
16
  end
16
17
 
@@ -18,14 +19,15 @@ module Mjml
18
19
  #
19
20
  # @return [String]
20
21
  def render
21
- in_tmp_file = Tempfile.open(["in", ".mjml"]) do |file|
22
+ in_tmp_file = Tempfile.open(['in', '.mjml']) do |file|
22
23
  file.write(input)
23
24
  file # return tempfile from block so #unlink works later
24
25
  end
25
26
  run(in_tmp_file.path, Mjml.beautify, Mjml.minify, Mjml.validation_level)
26
- rescue
27
+ rescue StandardError
27
28
  raise if Mjml.raise_render_exception
28
- ""
29
+
30
+ ''
29
31
  ensure
30
32
  in_tmp_file.unlink
31
33
  end
@@ -33,22 +35,18 @@ module Mjml
33
35
  # Exec mjml command
34
36
  #
35
37
  # @return [String] The result as string
36
- def run(in_tmp_file, beautify=true, minify=false, validation_level="soft")
37
- Tempfile.create(["out", ".html"]) do |out_tmp_file|
38
- command = "-r #{in_tmp_file} -o #{out_tmp_file.path} --config.beautify #{beautify} --config.minify #{minify} --config.validationLevel #{validation_level}"
39
- _, stderr, _ = Mjml.run_mjml(command)
40
- raise ParseError.new(stderr.chomp) unless stderr.blank?
38
+ # rubocop:disable Style/OptionalBooleanParameter: Fixing this offense would imply a change in the public API.
39
+ def run(in_tmp_file, beautify = true, minify = false, validation_level = 'strict')
40
+ Tempfile.create(['out', '.html']) do |out_tmp_file|
41
+ command = "-r #{in_tmp_file} -o #{out_tmp_file.path} " \
42
+ "--config.beautify #{beautify} --config.minify #{minify} --config.validationLevel #{validation_level}"
43
+ _, stderr, status = Mjml.run_mjml(command)
44
+ raise ParseError, stderr.chomp unless status.success?
45
+
46
+ Mjml.logger.warn(stderr.chomp) if stderr.present?
41
47
  out_tmp_file.read
42
48
  end
43
49
  end
44
-
45
- private
46
-
47
- # Get mjml bin path
48
- #
49
- # @return [String]
50
- def mjml_bin
51
- Mjml::BIN
52
- end
50
+ # rubocop:enable Style/OptionalBooleanParameter
53
51
  end
54
52
  end
data/lib/mjml/railtie.rb CHANGED
@@ -1,11 +1,18 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Mjml
2
4
  class Railtie < Rails::Railtie
3
5
  config.mjml = Mjml
4
- config.app_generators.mailer :template_engine => :mjml
6
+ config.app_generators.mailer template_engine: :mjml
5
7
 
6
- initializer "mjml-rails.register_template_handler" do
8
+ initializer 'mjml-rails.register_template_handler' do
7
9
  ActionView::Template.register_template_handler :mjml, Mjml::Handler.new
8
- Mime::Type.register_alias "text/html", :mjml
10
+ Mime::Type.register_alias 'text/html', :mjml
11
+ end
12
+
13
+ config.to_prepare do
14
+ # make sure we have a valid mjml binary
15
+ Mjml.valid_mjml_binary
9
16
  end
10
17
  end
11
18
  end
data/lib/mjml/version.rb CHANGED
@@ -1,4 +1,6 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Mjml
2
- # Version number no longer matches MJML.io version
3
- VERSION = "4.4.2"
4
+ # Version number no longer matches MJML.io version
5
+ VERSION = '4.7.0'
4
6
  end
data/lib/mjml-rails.rb CHANGED
@@ -1 +1,5 @@
1
- require "mjml"
1
+ # rubocop:disable Naming/FileName
2
+ # frozen_string_literal: true
3
+
4
+ require 'mjml'
5
+ # rubocop:enable Naming/FileName
data/lib/mjml.rb CHANGED
@@ -1,21 +1,34 @@
1
- require "rails/version"
2
- require "action_view"
3
- require "action_view/template"
4
- require "mjml/mjmltemplate"
5
- require "mjml/railtie"
6
- require "rubygems"
7
- require "open3"
1
+ # frozen_string_literal: true
8
2
 
9
- module Mjml
10
- mattr_accessor :template_language, :raise_render_exception, :mjml_binary_version_supported, :mjml_binary_error_string, :beautify, :minify, :validation_level
3
+ require 'rubygems'
4
+ require 'open3'
5
+
6
+ require 'mjml/handler'
7
+ require 'mjml/parser'
11
8
 
12
- @@template_language = :erb
13
- @@raise_render_exception = true
14
- @@mjml_binary_version_supported = "4."
15
- @@mjml_binary_error_string = "Couldn't find the MJML #{Mjml.mjml_binary_version_supported} binary.. have you run $ npm install mjml?"
16
- @@beautify = true
17
- @@minify = false
18
- @@validation_level = "soft"
9
+ require 'mjml/railtie' if defined?(Rails)
10
+
11
+ module Mjml
12
+ mattr_accessor \
13
+ :beautify,
14
+ :minify,
15
+ :mjml_binary,
16
+ :mjml_binary_error_string,
17
+ :mjml_binary_version_supported,
18
+ :raise_render_exception,
19
+ :template_language,
20
+ :validation_level
21
+
22
+ mattr_writer :valid_mjml_binary
23
+
24
+ self.template_language = :erb
25
+ self.raise_render_exception = true
26
+ self.mjml_binary_version_supported = '4.'
27
+ self.mjml_binary_error_string = "Couldn't find the MJML #{Mjml.mjml_binary_version_supported} binary.." \
28
+ ' have you run $ npm install mjml?'
29
+ self.beautify = true
30
+ self.minify = false
31
+ self.validation_level = 'strict'
19
32
 
20
33
  def self.check_version(bin)
21
34
  stdout, _, status = run_mjml('--version', mjml_bin: bin)
@@ -24,33 +37,57 @@ module Mjml
24
37
  false
25
38
  end
26
39
 
27
- def self.run_mjml(args, mjml_bin: nil)
28
- mjml_bin ||= BIN
29
-
40
+ def self.run_mjml(args, mjml_bin: valid_mjml_binary)
30
41
  Open3.capture3("#{mjml_bin} #{args}")
31
42
  end
32
43
 
33
- def self.discover_mjml_bin
34
- # Check for local install of MJML with yarn
35
- yarn_bin = `which yarn`.chomp
36
- if yarn_bin.present?
37
- mjml_bin = "#{yarn_bin} run mjml"
38
- return mjml_bin if check_version(mjml_bin)
44
+ def self.valid_mjml_binary
45
+ self.valid_mjml_binary = @@valid_mjml_binary ||
46
+ check_for_custom_mjml_binary ||
47
+ check_for_yarn_mjml_binary ||
48
+ check_for_npm_mjml_binary ||
49
+ check_for_global_mjml_binary
50
+
51
+ return @@valid_mjml_binary if @@valid_mjml_binary
52
+
53
+ puts Mjml.mjml_binary_error_string
54
+ end
55
+
56
+ def self.check_for_custom_mjml_binary
57
+ if const_defined?('BIN') && Mjml::BIN.present?
58
+ logger.warn('Setting `Mjml::BIN` is deprecated and will be removed in a future version! ' \
59
+ 'Please use `Mjml.mjml_binary=` instead.')
60
+ self.mjml_binary = Mjml::BIN
61
+ remove_const 'BIN'
39
62
  end
40
63
 
41
- # Check for a local install of MJML with npm
64
+ return if mjml_binary.blank?
65
+
66
+ return mjml_binary if check_version(mjml_binary)
67
+
68
+ raise "MJML.mjml_binary is set to '#{mjml_binary}' but MJML-Rails could not validate that " \
69
+ 'it is a valid MJML binary. Please check your configuration.'
70
+ end
71
+
72
+ def self.check_for_yarn_mjml_binary
73
+ yarn_bin = `which yarn`.chomp
74
+ return if yarn_bin.blank?
75
+
76
+ mjml_bin = "#{yarn_bin} run mjml"
77
+ return mjml_bin if check_version(mjml_bin)
78
+ end
79
+
80
+ def self.check_for_npm_mjml_binary
42
81
  npm_bin = `which npm`.chomp
43
- if npm_bin.present? && (installer_path = bin_path_from(npm_bin)).present?
44
- mjml_bin = File.join(installer_path, 'mjml')
45
- return mjml_bin if check_version(mjml_bin)
46
- end
82
+ return unless npm_bin.present? && (installer_path = bin_path_from(npm_bin)).present?
83
+
84
+ mjml_bin = File.join(installer_path, 'mjml')
85
+ return mjml_bin if check_version(mjml_bin)
86
+ end
47
87
 
48
- # Check for a global install of MJML
88
+ def self.check_for_global_mjml_binary
49
89
  mjml_bin = `which mjml`.chomp
50
90
  return mjml_bin if mjml_bin.present? && check_version(mjml_bin)
51
-
52
- puts Mjml.mjml_binary_error_string
53
- nil
54
91
  end
55
92
 
56
93
  def self.bin_path_from(package_manager)
@@ -63,37 +100,9 @@ module Mjml
63
100
  nil
64
101
  end
65
102
 
66
- BIN = discover_mjml_bin
67
-
68
- class Handler
69
- def template_handler
70
- @_template_handler ||= ActionView::Template.registered_template_handler(Mjml.template_language)
71
- end
72
-
73
- # Optional second source parameter to make it work with Rails >= 6:
74
- # Beginning with Rails 6 template handlers get the source of the template as the second
75
- # parameter.
76
- def call(template, source = nil)
77
- compiled_source =
78
- if Rails::VERSION::MAJOR >= 6
79
- template_handler.call(template, source)
80
- else
81
- template_handler.call(template)
82
- end
83
-
84
- # Per MJML v4 syntax documentation[0] valid/render'able document MUST start with <mjml> root tag
85
- # If we get here and template source doesn't start with one it means
86
- # that we are rendering partial named according to legacy naming convention (partials ending with '.mjml')
87
- # Therefore we skip MJML processing and return raw compiled source. It will be processed
88
- # by MJML library when top-level layout/template is rendered
89
- #
90
- # [0] - https://github.com/mjmlio/mjml/blob/master/doc/guide.md#mjml
91
- if compiled_source =~ /<mjml(.+)?>/i
92
- "Mjml::Mjmltemplate.to_html(begin;#{compiled_source};end).html_safe"
93
- else
94
- compiled_source
95
- end
96
- end
103
+ def self.discover_mjml_bin
104
+ logger.warn('`Mjml.discover_mjml_bin` is deprecated and has no effect anymore! ' \
105
+ 'Please use `Mjml.mjml_binary=` to set a custom MJML binary.')
97
106
  end
98
107
 
99
108
  def self.setup
@@ -105,7 +114,7 @@ module Mjml
105
114
 
106
115
  def logger
107
116
  @logger ||= Logger.new($stdout).tap do |log|
108
- log.progname = self.name
117
+ log.progname = name
109
118
  end
110
119
  end
111
120
  end
@@ -1,26 +1,28 @@
1
- require "test_helper"
2
- require "generators/mjml/mailer/mailer_generator"
1
+ # frozen_string_literal: true
2
+
3
+ require 'test_helper'
4
+ require 'generators/mjml/mailer/mailer_generator'
3
5
 
4
6
  class GeneratorTest < Rails::Generators::TestCase
5
7
  tests Mjml::Generators::MailerGenerator
6
- destination File.expand_path("../tmp", __FILE__)
8
+ destination File.expand_path('tmp', __dir__)
7
9
  setup :prepare_destination
8
10
 
9
- test "assert all views are properly created with given name" do
10
- run_generator %w(notifier foo bar baz)
11
+ test 'assert all views are properly created with given name' do
12
+ run_generator %w[notifier foo bar baz]
11
13
 
12
- assert_file "app/views/layouts/mailer.html.mjml" do |mailer|
13
- assert_match "<mjml>", mailer
14
- assert_match "<mj-body>", mailer
15
- assert_match "<%= yield %>", mailer
14
+ assert_file 'app/views/layouts/mailer.html.mjml' do |mailer|
15
+ assert_match '<mjml>', mailer
16
+ assert_match '<mj-body>', mailer
17
+ assert_match '<%= yield %>', mailer
16
18
  end
17
19
 
18
- assert_file "app/views/notifier_mailer/foo.html.erb" do |template|
19
- assert_match "<%= @greeting %>", template
20
- assert_match "app/views/notifier_mailer/foo.html.erb", template
20
+ assert_file 'app/views/notifier_mailer/foo.html.erb' do |template|
21
+ assert_match '<%= @greeting %>', template
22
+ assert_match 'app/views/notifier_mailer/foo.html.erb', template
21
23
  end
22
24
 
23
- assert_file "app/views/notifier_mailer/bar.html.erb"
24
- assert_file "app/views/notifier_mailer/baz.html.erb"
25
+ assert_file 'app/views/notifier_mailer/bar.html.erb'
26
+ assert_file 'app/views/notifier_mailer/baz.html.erb'
25
27
  end
26
28
  end
data/test/mjml_test.rb CHANGED
@@ -1,89 +1,160 @@
1
- require "test_helper"
1
+ # frozen_string_literal: true
2
+
3
+ require 'test_helper'
2
4
 
3
5
  class NotifierMailer < ActionMailer::Base
4
- self.view_paths = File.expand_path("../views", __FILE__)
6
+ self.view_paths = File.expand_path('views', __dir__)
5
7
 
6
- layout "default"
8
+ layout 'default'
7
9
 
8
10
  def inform_contact(recipient)
9
11
  @recipient = recipient
10
12
 
11
- mail(to: @recipient, from: "app@example.com") do |format|
13
+ mail(to: @recipient, from: 'app@example.com') do |format|
12
14
  format.text
13
15
  format.html
14
16
  end
15
17
  end
18
+
19
+ def invalid_template(recipient)
20
+ @recipient = recipient
21
+
22
+ mail(to: @recipient, from: 'app@example.com') do |format|
23
+ format.html
24
+ format.text
25
+ end
26
+ end
16
27
  end
17
28
 
18
29
  class NoLayoutMailer < ActionMailer::Base
19
- self.view_paths = File.expand_path("../views", __FILE__)
30
+ self.view_paths = File.expand_path('views', __dir__)
20
31
 
21
32
  layout nil
22
33
 
23
34
  def inform_contact(recipient)
24
35
  @recipient = recipient
25
36
 
26
- mail(to: @recipient, from: "app@example.com") do |format|
27
- format.mjml
28
- end
37
+ mail(to: @recipient, from: 'app@example.com', &:mjml)
29
38
  end
30
39
 
31
40
  def with_owa(recipient)
32
41
  @recipient = recipient
33
42
 
34
- mail(to: @recipient, from: "app@example.com") do |format|
35
- format.mjml
36
- end
43
+ mail(to: @recipient, from: 'app@example.com', &:mjml)
37
44
  end
38
45
  end
39
46
 
40
47
  class NotifierMailerTest < ActiveSupport::TestCase
41
- test "MJML layout based multipart email is generated correctly" do
42
- email = NotifierMailer.inform_contact("user@example.com")
48
+ test 'MJML layout based multipart email is generated correctly' do
49
+ email = NotifierMailer.inform_contact('user@example.com')
43
50
 
44
- assert_equal "multipart/alternative", email.mime_type
51
+ assert_equal 'multipart/alternative', email.mime_type
45
52
 
46
53
  # To debug tests:
47
54
  # Mjml.logger.info email.mime_type
48
55
  # Mjml.logger.info email.to_s
49
56
  # Mjml.logger.info email.html_part.body
50
57
 
51
- refute email.html_part.body.match(%r{</?mj.+?>})
52
- assert email.html_part.body.match(/<body>/)
58
+ assert_not email.html_part.body.match(%r{</?mj.+?>})
59
+ assert email.html_part.body.include?('<body')
53
60
  assert email.html_part.body.match(/Hello, user@example.com!/)
54
- assert email.html_part.body.match(%r{<h2>We inform you about something</h2>})
61
+ assert email.html_part.body.include?('<h2>We inform you about something</h2>')
55
62
  assert email.html_part.body.match(%r{<a href="https://www.example.com">this link</a>})
56
- assert email.html_part.body.match(/tracking-code-123/)
63
+ assert email.html_part.body.include?('tracking-code-123')
57
64
 
58
- assert email.text_part.body.match(/We inform you about something/)
65
+ assert email.text_part.body.include?('We inform you about something')
59
66
  assert email.text_part.body.match(%r{Please visit https://www.example.com})
60
67
  end
68
+
69
+ test 'Invalid template raises error with validation level strict' do
70
+ with_settings(validation_level: 'strict') do
71
+ email = NotifierMailer.invalid_template('user@example.com')
72
+ assert_raise(ActionView::Template::Error) { email.html_part.body.to_s }
73
+ end
74
+ end
75
+
76
+ test 'Invalid template gets compiled with validation level soft' do
77
+ # suppress warning of MJML binary
78
+ Mjml.logger.stubs(:warn)
79
+
80
+ with_settings(validation_level: 'soft') do
81
+ email = NotifierMailer.invalid_template('user@example.com')
82
+ assert email.text_part.body.include?('This is valid')
83
+ assert email.html_part.body.include?('This is valid')
84
+ assert_not email.html_part.body.include?('This is invalid')
85
+ end
86
+ end
61
87
  end
62
88
 
63
89
  class NotifierMailerTest < ActiveSupport::TestCase
64
- test "old mjml-rails configuration style MJML template is rendered correctly" do
65
- email = NoLayoutMailer.inform_contact("user@example.com")
90
+ test 'old mjml-rails configuration style MJML template is rendered correctly' do
91
+ email = NoLayoutMailer.inform_contact('user@example.com')
66
92
 
67
- assert_equal "text/html", email.mime_type
93
+ assert_equal 'text/html', email.mime_type
68
94
 
69
- refute email.body.match(%r{</?mj.+?>})
70
- assert email.body.match(/<body>/)
95
+ assert_not email.body.match(%r{</?mj.+?>})
96
+ assert email.body.include?('<body')
71
97
  assert email.body.match(/Welcome, user@example.com!/)
72
- assert email.body.match(%r{<h2>We inform you about something</h2>})
98
+ assert email.body.include?('<h2>We inform you about something</h2>')
73
99
  assert email.body.match(%r{<a href="https://www.example.com">this link</a>})
74
- refute email.body.match(/tracking-code-123/)
100
+ assert_not email.body.include?('tracking-code-123')
75
101
  end
76
102
 
77
- test "old mjml-rails MJML template with owa is rendered correctly" do
78
- email = NoLayoutMailer.with_owa("user@example.com")
103
+ test 'old mjml-rails MJML template with owa is rendered correctly' do
104
+ email = NoLayoutMailer.with_owa('user@example.com')
79
105
 
80
- assert_equal "text/html", email.mime_type
106
+ assert_equal 'text/html', email.mime_type
81
107
 
82
- refute email.body.match(%r{</?mj.+?>})
83
- assert email.body.match(/<body>/)
108
+ assert_not email.body.match(%r{</?mj.+?>})
109
+ assert email.body.include?('<body')
84
110
  assert email.body.match(/Welcome, user@example.com!/)
85
- assert email.body.match(%r{<h2>We inform you about something</h2>})
111
+ assert email.body.include?('<h2>We inform you about something</h2>')
86
112
  assert email.body.match(%r{<a href="https://www.example.com">this link</a>})
87
- refute email.body.match(/tracking-code-123/)
113
+ assert_not email.body.include?('tracking-code-123')
114
+ end
115
+ end
116
+
117
+ describe Mjml do
118
+ describe '#valid_mjml_binary' do
119
+ before do
120
+ Mjml.mjml_binary = nil
121
+ Mjml.valid_mjml_binary = nil
122
+ end
123
+
124
+ after do
125
+ Mjml.mjml_binary = nil
126
+ Mjml.valid_mjml_binary = nil
127
+ end
128
+
129
+ it 'can be set to a custom value with mjml_binary if version is correct' do
130
+ Mjml.mjml_binary = 'some custom value'
131
+ Mjml.stub :check_version, true do
132
+ expect(Mjml.valid_mjml_binary).must_equal 'some custom value'
133
+ end
134
+ end
135
+
136
+ it 'raises an error if mjml_binary is invalid' do
137
+ Mjml.mjml_binary = 'some custom value'
138
+ err = expect { Mjml.valid_mjml_binary }.must_raise(StandardError)
139
+ assert(err.message.start_with?("MJML.mjml_binary is set to 'some custom value' " \
140
+ 'but MJML-Rails could not validate that it is a valid MJML binary'))
141
+ end
142
+
143
+ it 'honors old Mjml::BIN way of setting custom binary' do
144
+ silence_warnings { Mjml::BIN = 'set by old way' }
145
+ Mjml.logger.expects(:warn).with(regexp_matches(/Setting `Mjml::BIN` is deprecated/))
146
+ err = expect { Mjml.valid_mjml_binary }.must_raise(StandardError)
147
+ assert(err.message.start_with?("MJML.mjml_binary is set to 'set by old way' " \
148
+ 'but MJML-Rails could not validate that it is a valid MJML binary'))
149
+ end
150
+
151
+ it 'ignores empty Mjml::BIN' do
152
+ Mjml::BIN = ''
153
+ Mjml.mjml_binary = 'set by mjml_binary'
154
+
155
+ err = expect { Mjml.valid_mjml_binary }.must_raise(StandardError)
156
+ assert(err.message.start_with?("MJML.mjml_binary is set to 'set by mjml_binary' " \
157
+ 'but MJML-Rails could not validate that it is a valid MJML binary'))
158
+ end
88
159
  end
89
160
  end
data/test/parser_test.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'test_helper'
2
4
 
3
5
  describe Mjml::Parser do
@@ -13,54 +15,42 @@ describe Mjml::Parser do
13
15
  parser.stubs(:run).raises(error)
14
16
  end
15
17
 
16
- describe 'when render exception raising is enabled' do
17
- before do
18
- Mjml.setup do |config|
19
- config.raise_render_exception = true
20
- end
21
- end
22
-
23
- it 'raises exception' do
18
+ it 'raises exception with render exception enabled' do
19
+ with_settings(raise_render_exception: true) do
24
20
  err = expect { parser.render }.must_raise(custom_error_class)
25
21
  expect(err.message).must_equal error.message
26
22
  end
27
23
  end
28
24
 
29
- describe 'when render exception raising is disabled' do
30
- before do
31
- Mjml.setup do |config|
32
- config.raise_render_exception = false
33
- end
34
- end
35
-
36
- it 'returns empty string' do
25
+ it 'returns empty string with exception raising disabled' do
26
+ with_settings(raise_render_exception: false) do
37
27
  expect(parser.render).must_equal ''
38
28
  end
39
29
  end
40
30
  end
41
31
 
42
32
  describe 'can read beautify, minify, and validation_level configs' do
43
- it 'use defaults if no config is set' do
33
+ it 'uses defaults if no config is set' do
44
34
  expect(Mjml.beautify).must_equal(true)
45
35
  expect(Mjml.minify).must_equal(false)
46
- expect(Mjml.validation_level).must_equal('soft')
36
+ expect(Mjml.validation_level).must_equal('strict')
47
37
  end
48
38
 
49
- it 'use setup config' do
39
+ it 'uses setup config' do
50
40
  Mjml.setup do |config|
51
41
  config.beautify = false
52
42
  config.minify = true
53
- config.validation_level = 'strict'
43
+ config.validation_level = 'soft'
54
44
  end
55
45
 
56
46
  expect(Mjml.beautify).must_equal(false)
57
47
  expect(Mjml.minify).must_equal(true)
58
- expect(Mjml.validation_level).must_equal('strict')
48
+ expect(Mjml.validation_level).must_equal('soft')
59
49
 
60
50
  Mjml.setup do |config|
61
51
  config.beautify = true
62
52
  config.minify = false
63
- config.validation_level = 'soft'
53
+ config.validation_level = 'strict'
64
54
  end
65
55
  end
66
56
  end
@@ -69,7 +59,7 @@ describe Mjml::Parser do
69
59
  describe '#run' do
70
60
  describe 'when shell command failed' do
71
61
  it 'raises exception' do
72
- err = expect { parser.run "/tmp/non_existent_file.mjml" }.must_raise(Mjml::Parser::ParseError)
62
+ err = expect { parser.run '/tmp/non_existent_file.mjml' }.must_raise(Mjml::Parser::ParseError)
73
63
  expect(err.message).must_include 'Command line error'
74
64
  end
75
65
  end
data/test/test_helper.rb CHANGED
@@ -1,21 +1,24 @@
1
- require "rubygems"
2
- require "bundler"
1
+ # frozen_string_literal: true
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
3
5
  Bundler.setup
4
6
 
5
- require "minitest/autorun"
6
- require "active_support/test_case"
7
+ require 'minitest/autorun'
8
+ require 'active_support/test_case'
7
9
 
8
- require "action_mailer"
9
- require "rails/railtie"
10
- require "rails/generators"
11
- require "rails/generators/test_case"
10
+ require 'action_mailer'
11
+ require 'rails/railtie'
12
+ require 'rails/generators'
13
+ require 'rails/generators/test_case'
12
14
  require 'mocha/minitest'
15
+ require 'byebug'
13
16
 
14
17
  # require "minitest/reporters"
15
18
  # Minitest::Reporters.use!
16
19
 
17
- $:.unshift File.expand_path("../../lib", __FILE__)
18
- require "mjml"
20
+ $LOAD_PATH.unshift File.expand_path('../lib', __dir__)
21
+ require 'mjml'
19
22
  Mjml::Railtie.run_initializers
20
23
 
21
24
  ActiveSupport::TestCase.test_order = :sorted if ActiveSupport::TestCase.respond_to? :test_order=
@@ -25,3 +28,18 @@ I18n.enforce_available_locales = false
25
28
 
26
29
  ActionMailer::Base.delivery_method = :test
27
30
  ActionMailer::Base.perform_deliveries = true
31
+
32
+ def with_settings(settings)
33
+ original_settings = settings.each_with_object({}) { |(key, _), agg| agg[key] = Mjml.public_send(key) }
34
+ settings.each { |key, value| Mjml.public_send("#{key}=", value) }
35
+ yield
36
+ ensure
37
+ original_settings.each { |key, value| Mjml.public_send("#{key}=", value) }
38
+ end
39
+
40
+ # Suppress all ruby warnings of the mail gem, see:
41
+ # * https://github.com/mikel/mail/issues/1424
42
+ # * https://github.com/mikel/mail/issues/1384
43
+ # * https://github.com/mikel/mail/pull/1162
44
+ require 'warning'
45
+ Warning.ignore(//, %r{.*gems/mail.*/lib/mail/})
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.4.2
4
+ version: 4.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simon Loffler
@@ -11,32 +11,130 @@ bindir: bin
11
11
  cert_chain:
12
12
  - |
13
13
  -----BEGIN CERTIFICATE-----
14
- MIIEKDCCApCgAwIBAgIBATANBgkqhkiG9w0BAQsFADAfMR0wGwYDVQQDDBR5b3Vy
15
- L0RDPWVtYWlsL0RDPWNvbTAeFw0yMDExMjIwNTA5MjJaFw0yMTExMjIwNTA5MjJa
16
- MB8xHTAbBgNVBAMMFHlvdXIvREM9ZW1haWwvREM9Y29tMIIBojANBgkqhkiG9w0B
17
- AQEFAAOCAY8AMIIBigKCAYEAmYphpc2KJNqmKAAKTE53F59mnVv2aW8r5NFDZqG0
18
- DF6V8N5rdWanaMLlo1HyU9r7D1f/h7O/LnjZemvgH6MROd19Qe64GIdIPRXC/ZxM
19
- cTBNC7GMoZf9LomBmg8sXnoL0Z2enUP6BV716I00EecxrEb8drtvZlRwjUgRcZrv
20
- iEaanYYp1Sw3+koyOsof/xYb3Pn2TAh9UE58lbVDpf88zc74ij3Vs3+LW/k+jZzh
21
- pzo7qq47XeVNGWtVDGm3dk8QLrIyQdk28B2ZRJ+HeuLEgx7ASDYFVZc05QlAjehS
22
- 4k37CIgF0ODDnscoSNNb6toFzaiD/kU9+ManRj871qOAMDlcX6cM4Wl08xfXZsxh
23
- VgmIv7vFoSkBDw6t3xrHGD1HiYYQl2tFQsS9D/X9I+1ArChtUTSxEyN6VGP1YVd6
24
- jsf4A/eMNRO6+udEQjYHontemi1xFeeyb6PDbP14oLMOls73fKvGZ3eW5uO3qCOb
25
- tKhPFou/w1GgU3vR3O26Q3EZAgMBAAGjbzBtMAkGA1UdEwQCMAAwCwYDVR0PBAQD
26
- AgSwMB0GA1UdDgQWBBTx6I3ZLm1G7VCtTJWWSKR2qv6x7TAZBgNVHREEEjAQgQ55
27
- b3VyQGVtYWlsLmNvbTAZBgNVHRIEEjAQgQ55b3VyQGVtYWlsLmNvbTANBgkqhkiG
28
- 9w0BAQsFAAOCAYEAKCpNu5+MmYNrb+oOws9m8mghO4KDO53EQsfHtRcpsBxzwzV3
29
- MLO4el5fMiAiv2PrULEWVyEoe3k65bEiSEQP7m7w02B02OGugXNzwbetG56gogFy
30
- aJ4VJ95aiPEwDmGORLg7RmZcL/07ikDfb96ebPn3v2REYN2lWrqu4fT1MdTmA+hZ
31
- vhfqJeSuWM5wNsWxA66SgbQe8BMHcsqV1CTG+Ir8FIAHzfa+c7CNke/28htRKYJV
32
- 6+lk55Ueov5TjjgLTUvjdqbAEtyCZpgxe2e0o3xqKh5d5YjWVQ4mSNvBsqK7UXOx
33
- MGsePVBV9lnSFEJkGB3iOvavQSVUvqybF+yk6DrJR9iZtKCvAqd96PjkcFoM19dG
34
- 5ofv88TRZwXM9lWn4UKuekSSF1ElH3UBVDbH4zEHaOzrOvgfnZw3VteDigwfmmwF
35
- lsAqKbu4nrHhtGhkwdYbflf2URJTUxXGptrnPYV7okmEg4rsykK3RAsZ6kMNdKmx
36
- DcQ7RSt1TU5eck6c
14
+ MIIEPDCCAqSgAwIBAgIBATANBgkqhkiG9w0BAQsFADAkMSIwIAYDVQQDDBlzaWdo
15
+ bW9uL0RDPXNpZ2htb24vREM9Y29tMB4XDTIxMTIxODA1MDcyM1oXDTIyMTIxODA1
16
+ MDcyM1owJDEiMCAGA1UEAwwZc2lnaG1vbi9EQz1zaWdobW9uL0RDPWNvbTCCAaIw
17
+ DQYJKoZIhvcNAQEBBQADggGPADCCAYoCggGBALvTbM9xGlGQ9pByLEAJjAqc6U76
18
+ 64uCOSIkgIFbC4iQdU5vzB/w4Y+mjgkH4oMsuW2NQfFBV+xI3jxQA0dN4qMgHooB
19
+ AWT/CSk0AAqTY1qCfCSASHLUWb5ZxURvsHmlXX/HCLX9bPcaYB0nQ+VT/u0lCicZ
20
+ beXMczHsNAj8f3ZJWDR9mw5OYc6cdGHM7Se3sqrmEsMYL9s8d08tChDcllxKV7cE
21
+ r2zb0oPrRFoYpakOIz1ViCl4KqBpQsDqXbwEw1kDCkKMXGHCsmDKML55kXsVVu4Q
22
+ 9vqGvtEuvseWsDpKb6Psy4nJoktswhotUf21dNVM9k8ufXNaWvZed+cYnBFPLdQV
23
+ daaEqh6hIC/yUP98D5u+xmTYLRQQEsjhkbdfoLmB8UOwrsEZu79TXN6Iq4MZqmBe
24
+ qkCTlXOMaO/EbWVRRvs64iibC/boVVlXu6RZCVNyzXEvYxg/zyl0zjS8KPR8Vf4f
25
+ RKOUVKJCcL/nW4VZ1mvmJtiXI3eARaJdrBEjjQIDAQABo3kwdzAJBgNVHRMEAjAA
26
+ MAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQUC9Ln2Rotb61VZFq2rxBPP7sJIiUwHgYD
27
+ VR0RBBcwFYETc2lnaG1vbkBzaWdobW9uLmNvbTAeBgNVHRIEFzAVgRNzaWdobW9u
28
+ QHNpZ2htb24uY29tMA0GCSqGSIb3DQEBCwUAA4IBgQBN7i1ChHKDNa5ceCXUXdJ/
29
+ ZQnVQTx2KMvWwZ6qpkIWFbzwwL5w/xQdhQbLMjuaie5X1ZYOB9753ipw3tvl7iJz
30
+ vHEdTcOWAzMzHytySVcSa2DhanDopC+hrO5N+GoQ+5X9CN+xKG1Png4ho4FsuUtI
31
+ fESG8Kb48iNlpLGbfcM8Nqm/mYk/Xwqh3aSVb2E1NVUNr3QW84xB/xmzy2d9qNBm
32
+ 0GecfnBmH+ARmR9Qk9H7YjtnhQv1W2wOBiz1k6GeO8wMLKRRHVI2TGcPR8AqhQGd
33
+ ejWL8tjMzIw5ggxro3WDklV1hn0iFSeWXNWd9tN40PjLYZqZ3krQ2wWgcgw/9eC9
34
+ yVr+12iQ7XbbPqlveO/FhP4gLa8e2q1TgWjYAXIaM61em83Dlm/3p75ch0YCB3X5
35
+ R9NsaxhBfawJEJcYoPZflGkLjJU8pjSuvIW5+rNgAiqY8D37hTtZMu/n2Fz8Qp24
36
+ 7EZetZmcvBzARf8vQSJjga3y0Bftk8u7LmblOEWddzE=
37
37
  -----END CERTIFICATE-----
38
- date: 2020-11-27 00:00:00.000000000 Z
39
- dependencies: []
38
+ date: 2021-12-18 00:00:00.000000000 Z
39
+ dependencies:
40
+ - !ruby/object:Gem::Dependency
41
+ name: byebug
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ type: :development
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ - !ruby/object:Gem::Dependency
55
+ name: mocha
56
+ requirement: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - '='
59
+ - !ruby/object:Gem::Version
60
+ version: 1.4.0
61
+ type: :development
62
+ prerelease: false
63
+ version_requirements: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - '='
66
+ - !ruby/object:Gem::Version
67
+ version: 1.4.0
68
+ - !ruby/object:Gem::Dependency
69
+ name: rails
70
+ requirement: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ type: :development
76
+ prerelease: false
77
+ version_requirements: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ - !ruby/object:Gem::Dependency
83
+ name: rubocop
84
+ requirement: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: 1.23.0
89
+ type: :development
90
+ prerelease: false
91
+ version_requirements: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: 1.23.0
96
+ - !ruby/object:Gem::Dependency
97
+ name: rubocop-performance
98
+ requirement: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: 1.12.0
103
+ type: :development
104
+ prerelease: false
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: 1.12.0
110
+ - !ruby/object:Gem::Dependency
111
+ name: rubocop-rails
112
+ requirement: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - "~>"
115
+ - !ruby/object:Gem::Version
116
+ version: 2.12.4
117
+ type: :development
118
+ prerelease: false
119
+ version_requirements: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - "~>"
122
+ - !ruby/object:Gem::Version
123
+ version: 2.12.4
124
+ - !ruby/object:Gem::Dependency
125
+ name: warning
126
+ requirement: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - '='
129
+ - !ruby/object:Gem::Version
130
+ version: 1.2.1
131
+ type: :development
132
+ prerelease: false
133
+ version_requirements: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - '='
136
+ - !ruby/object:Gem::Version
137
+ version: 1.2.1
40
138
  description: Render MJML + ERb template views in Rails
41
139
  email: sighmon@sighmon.com
42
140
  executables: []
@@ -50,20 +148,19 @@ files:
50
148
  - lib/generators/mjml/mailer/templates/view.html.erb
51
149
  - lib/mjml-rails.rb
52
150
  - lib/mjml.rb
53
- - lib/mjml/mjmltemplate.rb
151
+ - lib/mjml/handler.rb
54
152
  - lib/mjml/parser.rb
55
153
  - lib/mjml/railtie.rb
56
154
  - lib/mjml/version.rb
57
155
  - test/generator_test.rb
58
156
  - test/mjml_test.rb
59
157
  - test/parser_test.rb
60
- - test/template_test.rb
61
158
  - test/test_helper.rb
62
159
  homepage: https://github.com/sighmon/mjml-rails
63
160
  licenses:
64
161
  - MIT
65
162
  metadata: {}
66
- post_install_message: "Don't forget to install MJML e.g. \n$ npm install -g mjml"
163
+ post_install_message: "Don't forget to install MJML e.g. \n$ npm install mjml"
67
164
  rdoc_options: []
68
165
  require_paths:
69
166
  - lib
@@ -71,14 +168,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
71
168
  requirements:
72
169
  - - ">="
73
170
  - !ruby/object:Gem::Version
74
- version: '0'
171
+ version: '2.5'
75
172
  required_rubygems_version: !ruby/object:Gem::Requirement
76
173
  requirements:
77
174
  - - ">="
78
175
  - !ruby/object:Gem::Version
79
176
  version: '0'
80
177
  requirements: []
81
- rubygems_version: 3.1.4
178
+ rubygems_version: 3.1.6
82
179
  signing_key:
83
180
  specification_version: 4
84
181
  summary: MJML + ERb templates
@@ -86,5 +183,4 @@ test_files:
86
183
  - test/generator_test.rb
87
184
  - test/parser_test.rb
88
185
  - test/mjml_test.rb
89
- - test/template_test.rb
90
186
  - test/test_helper.rb
metadata.gz.sig CHANGED
Binary file
@@ -1,12 +0,0 @@
1
- require "mjml/parser"
2
-
3
- module Mjml
4
- mattr_accessor :processing_options, :renderer
5
- @@processing_options = {}
6
-
7
- class Mjmltemplate
8
- def self.to_html(compiled_source)
9
- Mjml::Parser.new(compiled_source).render.html_safe
10
- end
11
- end
12
- end
@@ -1,9 +0,0 @@
1
- require "test_helper"
2
-
3
- class MjmlTest < ActiveSupport::TestCase
4
-
5
- test 'with Mjmltemplate processor' do
6
- assert_not_equal "<mj-body></mj-body>", Mjml::Mjmltemplate.to_html("<mjml><mj-body><mj-section><mj-column></mj-column></mj-section></mj-body></mjml>").strip
7
- end
8
-
9
- end