mjml-rails 4.3.2 → 4.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/README.md +4 -0
- data/lib/mjml.rb +2 -1
- data/lib/mjml/parser.rb +3 -3
- data/lib/mjml/version.rb +1 -1
- data/test/parser_test.rb +8 -5
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 88e3f9ecbcbb4ddc89a64ae73dc35f62df462edc2e52a80ffcce8b76b17e7324
|
4
|
+
data.tar.gz: 44f3771373b38d7ba49ebee9ae6e503a4f094f2c7ab96bb0be88e6b3326ee38d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 60001f52fd6d52b7ed1babb9e1387e6488b7f05624ddc5565f411caf87c4455c1c92d47466216b84f7aec540ad3e19343c178c9c64f82f8751447f52500e2dce
|
7
|
+
data.tar.gz: 43df7639a83deb7ffa0fb2e13ce28c5d2e6faa357fb18d7415a1b3a7ea022d25875365653b989783de72d4f4b7a4453cf0bc340e36d4a9f69769807c93e8815e
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/README.md
CHANGED
@@ -89,8 +89,10 @@ If there are configurations you'd like change:
|
|
89
89
|
- render errors: defaults to `true` (errors raised)
|
90
90
|
- minify: defaults to `false` (not minified)
|
91
91
|
- beautify: defaults to `true` (beautified)
|
92
|
+
- validation_level: defaults to `soft` (MJML syntax validation)
|
92
93
|
|
93
94
|
```ruby
|
95
|
+
# config/initializers/mjml.rb
|
94
96
|
Mjml.setup do |config|
|
95
97
|
# set to `false` to ignore errors silently
|
96
98
|
config.raise_render_exception = true
|
@@ -98,12 +100,14 @@ Mjml.setup do |config|
|
|
98
100
|
# optimize the size of your email
|
99
101
|
config.beautify = false
|
100
102
|
config.minify = true
|
103
|
+
config.validation_level = "strict"
|
101
104
|
end
|
102
105
|
```
|
103
106
|
|
104
107
|
If you’d like to specify a different MJML binary to run other than `4.`:
|
105
108
|
|
106
109
|
```ruby
|
110
|
+
# config/initializers/mjml.rb
|
107
111
|
Mjml.setup do |config|
|
108
112
|
config.mjml_binary_version_supported = "3.3.5"
|
109
113
|
end
|
data/lib/mjml.rb
CHANGED
@@ -7,7 +7,7 @@ require "rubygems"
|
|
7
7
|
require "open3"
|
8
8
|
|
9
9
|
module Mjml
|
10
|
-
mattr_accessor :template_language, :raise_render_exception, :mjml_binary_version_supported, :mjml_binary_error_string, :beautify, :minify
|
10
|
+
mattr_accessor :template_language, :raise_render_exception, :mjml_binary_version_supported, :mjml_binary_error_string, :beautify, :minify, :validation_level
|
11
11
|
|
12
12
|
@@template_language = :erb
|
13
13
|
@@raise_render_exception = true
|
@@ -15,6 +15,7 @@ module Mjml
|
|
15
15
|
@@mjml_binary_error_string = "Couldn't find the MJML #{Mjml.mjml_binary_version_supported} binary.. have you run $ npm install mjml?"
|
16
16
|
@@beautify = true
|
17
17
|
@@minify = false
|
18
|
+
@@validation_level = "soft"
|
18
19
|
|
19
20
|
def self.check_version(bin)
|
20
21
|
IO.popen([bin, '--version']) { |io| io.read.include?("mjml-core: #{Mjml.mjml_binary_version_supported}") }
|
data/lib/mjml/parser.rb
CHANGED
@@ -22,7 +22,7 @@ module Mjml
|
|
22
22
|
file.write(input)
|
23
23
|
file # return tempfile from block so #unlink works later
|
24
24
|
end
|
25
|
-
run(in_tmp_file.path, Mjml.beautify, Mjml.minify)
|
25
|
+
run(in_tmp_file.path, Mjml.beautify, Mjml.minify, Mjml.validation_level)
|
26
26
|
rescue
|
27
27
|
raise if Mjml.raise_render_exception
|
28
28
|
""
|
@@ -33,9 +33,9 @@ module Mjml
|
|
33
33
|
# Exec mjml command
|
34
34
|
#
|
35
35
|
# @return [String] The result as string
|
36
|
-
def run(in_tmp_file, beautify=true, minify=false)
|
36
|
+
def run(in_tmp_file, beautify=true, minify=false, validation_level="soft")
|
37
37
|
Tempfile.create(["out", ".html"]) do |out_tmp_file|
|
38
|
-
command = "#{mjml_bin} -r #{in_tmp_file} -o #{out_tmp_file.path} --config.beautify #{beautify} --config.minify #{minify}"
|
38
|
+
command = "#{mjml_bin} -r #{in_tmp_file} -o #{out_tmp_file.path} --config.beautify #{beautify} --config.minify #{minify} --config.validationLevel #{validation_level}"
|
39
39
|
_, _, stderr, _ = Open3.popen3(command)
|
40
40
|
raise ParseError.new(stderr.read.chomp) unless stderr.eof?
|
41
41
|
out_tmp_file.read
|
data/lib/mjml/version.rb
CHANGED
data/test/parser_test.rb
CHANGED
@@ -38,20 +38,23 @@ describe Mjml::Parser do
|
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
-
describe 'can read beautify and
|
41
|
+
describe 'can read beautify, minify, and validation_level configs' do
|
42
42
|
it 'use defaults if no config is set' do
|
43
|
-
expect(Mjml.beautify).
|
44
|
-
expect(Mjml.minify).
|
43
|
+
expect(Mjml.beautify).must_equal(true)
|
44
|
+
expect(Mjml.minify).must_equal(false)
|
45
|
+
expect(Mjml.validation_level).must_equal('soft')
|
45
46
|
end
|
46
47
|
|
47
48
|
it 'use setup config' do
|
48
49
|
Mjml.setup do |config|
|
49
50
|
config.beautify = false
|
50
51
|
config.minify = true
|
52
|
+
config.validation_level = 'strict'
|
51
53
|
end
|
52
54
|
|
53
|
-
expect(Mjml.beautify).
|
54
|
-
expect(Mjml.minify).
|
55
|
+
expect(Mjml.beautify).must_equal(false)
|
56
|
+
expect(Mjml.minify).must_equal(true)
|
57
|
+
expect(Mjml.validation_level).must_equal('strict')
|
55
58
|
end
|
56
59
|
end
|
57
60
|
end
|
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
|
+
version: 4.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Simon Loffler
|
@@ -35,7 +35,7 @@ cert_chain:
|
|
35
35
|
HIqlmrbWgQA1FL8W9hf5pmQBhNu6zNDtZooPwDPGf0klvVt/Lkh4zjDHlO284UV5
|
36
36
|
Z3vePI5/udzlcrq80eIHh5Ch5NVPG8B7O1qMSwJo4to=
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date: 2020-
|
38
|
+
date: 2020-04-04 00:00:00.000000000 Z
|
39
39
|
dependencies: []
|
40
40
|
description: Render MJML + ERb template views in Rails
|
41
41
|
email: sighmon@sighmon.com
|
metadata.gz.sig
CHANGED
Binary file
|