mjml-rails 4.6.0 → 4.6.1

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: e001eb3b8f9abfa49b6fbf3e0e10d655fdeb38e68da79f55b348977f4a7082b8
4
- data.tar.gz: 7d78f4466486513af5d364c7ca3e5146724a6e9fc785b26cdf66ae5c626138fb
3
+ metadata.gz: 0a845d39f307dd7d452b0766805154e622aecaed3bbb3b4d392ead880939dc04
4
+ data.tar.gz: 13a7793222a8253ce62dd97f2a225379615515225e7f987deb23f5a93d6dbbfd
5
5
  SHA512:
6
- metadata.gz: 534c1c2975ff87a7e5bfed79bcbf19ec0d00ca16cf4a871faac3c9c89a348452aed2afb6197629598f473fd84943d67b64581a75139ca7e608ebcf4878004615
7
- data.tar.gz: 6b58532184a1d750fc2d4ae76508a52a3b86578b82fa501a6c4a01c7e9f03856fa2ac48522b0744536e573468233e7f6f54e6a8bd234dff6b58f58e02879ebd5
6
+ metadata.gz: f05c5580304ececa283ea79e17b61c7a281ce9b327d8aa3c73bacbdeaa8873049f3491243f03964e8fe0bf33f4c4e9ff2c0c70c2424100ae23f7d1a26d3322da
7
+ data.tar.gz: 111b70710d670a442564aa877652f3711c0ad9c934e1be8edd24a6fc0011f7019c3c9aaa58abec7cfcc338b7ca5ecac2aa6c3e3bd9af30cbb68402dcfa5a3165
@@ -1,2 +1,2 @@
1
- <K㠊l)Lsօ\i �|8'�1'}��T֑���`�k �B�O+���PDJ��Z��n�Q�VE�}�(!�z�4u�Є�Ы�K�tfd�61k)�XH9�Lz�t����+�y�r�(��C�BB6�Y��tSJA�{��ku������c"*A����'�.u��%s��֝�m���5E���u�O�4��ٴ�`<��sg]B�N>@�I��Z�uG��捤�S���'s��Vfq�am�!C�nU��r����1�ǁ >|�L�s.���7�-������,�(��r��1�,a�a����Qg�_H/եǷ��"Z ���x���ʺA�G�
2
- e[:��\�3]UTj ��~@PfzCq�f��a�
1
+ 79o0U@�[ �?,}Zw�� ���J�/͙�I��K�Ja3���x�972h;�_��wK���'}
2
+ S��jy'2N ��
data.tar.gz.sig CHANGED
Binary file
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
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
 
@@ -80,52 +80,61 @@ 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"`
104
+
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.
91
110
 
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).
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 `strict` (abort on any template error, see [MJML validation documentation](https://github.com/mjmlio/mjml/tree/master/packages/mjml-validator#validating-mjml) for possible values)
99
119
 
100
120
  ```ruby
101
121
  # config/initializers/mjml.rb
102
122
  Mjml.setup do |config|
103
- # ignore errors silently
123
+ # Use :haml as a template language
124
+ config.template_language = :haml
125
+
126
+ # Ignore errors silently
104
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
132
 
110
- # render illformed MJML templates, not recommended
133
+ # Render MJML templates with errors
111
134
  config.validation_level = "soft"
112
- end
113
- ```
114
-
115
- You can optionally provide a custom MJML binary if MJML-Rails cannot find it:
116
135
 
117
- ```ruby
118
- # config/initializers/mjml.rb
119
- Mjml.setup do |config|
136
+ # Use custom MJML binary with custom version
120
137
  config.mjml_binary = "/path/to/custom/mjml"
121
- end
122
- ```
123
-
124
- If you’d like to specify a different MJML version, set it like this:
125
-
126
- ```ruby
127
- # config/initializers/mjml.rb
128
- Mjml.setup do |config|
129
138
  config.mjml_binary_version_supported = "3.3.5"
130
139
  end
131
140
  ```
@@ -1,11 +1,11 @@
1
- require "rails/version"
2
- require "action_view"
3
- require "action_view/template"
4
- require "mjml/mjmltemplate"
5
- require "mjml/railtie"
6
1
  require "rubygems"
7
2
  require "open3"
8
3
 
4
+ require "mjml/handler"
5
+ require "mjml/parser"
6
+
7
+ require "mjml/railtie" if defined?(Rails)
8
+
9
9
  module Mjml
10
10
  mattr_accessor \
11
11
  :beautify,
@@ -99,37 +99,6 @@ module Mjml
99
99
  logger.warn('`Mjml.discover_mjml_bin` is deprecated and has no effect anymore! Please use `Mjml.mjml_binary=` to set a custom MJML binary.')
100
100
  end
101
101
 
102
- class Handler
103
- def template_handler
104
- @_template_handler ||= ActionView::Template.registered_template_handler(Mjml.template_language)
105
- end
106
-
107
- # Optional second source parameter to make it work with Rails >= 6:
108
- # Beginning with Rails 6 template handlers get the source of the template as the second
109
- # parameter.
110
- def call(template, source = nil)
111
- compiled_source =
112
- if Rails::VERSION::MAJOR >= 6
113
- template_handler.call(template, source)
114
- else
115
- template_handler.call(template)
116
- end
117
-
118
- # Per MJML v4 syntax documentation[0] valid/render'able document MUST start with <mjml> root tag
119
- # If we get here and template source doesn't start with one it means
120
- # that we are rendering partial named according to legacy naming convention (partials ending with '.mjml')
121
- # Therefore we skip MJML processing and return raw compiled source. It will be processed
122
- # by MJML library when top-level layout/template is rendered
123
- #
124
- # [0] - https://github.com/mjmlio/mjml/blob/master/doc/guide.md#mjml
125
- if compiled_source =~ /<mjml(.+)?>/i
126
- "Mjml::Mjmltemplate.to_html(begin;#{compiled_source};end).html_safe"
127
- else
128
- compiled_source
129
- end
130
- end
131
- end
132
-
133
102
  def self.setup
134
103
  yield self if block_given?
135
104
  end
@@ -0,0 +1,36 @@
1
+ require 'action_view'
2
+ require 'action_view/template'
3
+ require 'rails/version'
4
+
5
+ module Mjml
6
+ class Handler
7
+ def template_handler
8
+ @template_handler ||= ActionView::Template.registered_template_handler(Mjml.template_language)
9
+ end
10
+
11
+ # Optional second source parameter to make it work with Rails >= 6:
12
+ # Beginning with Rails 6 template handlers get the source of the template as the second
13
+ # parameter.
14
+ def call(template, source = nil)
15
+ compiled_source =
16
+ if Rails::VERSION::MAJOR >= 6
17
+ template_handler.call(template, source)
18
+ else
19
+ template_handler.call(template)
20
+ end
21
+
22
+ # Per MJML v4 syntax documentation[0] valid/render'able document MUST start with <mjml> root tag
23
+ # If we get here and template source doesn't start with one it means
24
+ # that we are rendering partial named according to legacy naming convention (partials ending with '.mjml')
25
+ # Therefore we skip MJML processing and return raw compiled source. It will be processed
26
+ # by MJML library when top-level layout/template is rendered
27
+ #
28
+ # [0] - https://github.com/mjmlio/mjml/blob/master/doc/guide.md#mjml
29
+ if compiled_source =~ /<mjml.*?>/i
30
+ "Mjml::Parser.new(begin;#{compiled_source};end).render.html_safe"
31
+ else
32
+ compiled_source
33
+ end
34
+ end
35
+ end
36
+ end
@@ -1,4 +1,4 @@
1
1
  module Mjml
2
2
  # Version number no longer matches MJML.io version
3
- VERSION = "4.6.0"
3
+ VERSION = "4.6.1"
4
4
  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.6.0
4
+ version: 4.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simon Loffler
@@ -35,7 +35,7 @@ cert_chain:
35
35
  lsAqKbu4nrHhtGhkwdYbflf2URJTUxXGptrnPYV7okmEg4rsykK3RAsZ6kMNdKmx
36
36
  DcQ7RSt1TU5eck6c
37
37
  -----END CERTIFICATE-----
38
- date: 2020-11-29 00:00:00.000000000 Z
38
+ date: 2020-12-19 00:00:00.000000000 Z
39
39
  dependencies: []
40
40
  description: Render MJML + ERb template views in Rails
41
41
  email: sighmon@sighmon.com
@@ -50,14 +50,13 @@ files:
50
50
  - lib/generators/mjml/mailer/templates/view.html.erb
51
51
  - lib/mjml-rails.rb
52
52
  - lib/mjml.rb
53
- - lib/mjml/mjmltemplate.rb
53
+ - lib/mjml/handler.rb
54
54
  - lib/mjml/parser.rb
55
55
  - lib/mjml/railtie.rb
56
56
  - lib/mjml/version.rb
57
57
  - test/generator_test.rb
58
58
  - test/mjml_test.rb
59
59
  - test/parser_test.rb
60
- - test/template_test.rb
61
60
  - test/test_helper.rb
62
61
  homepage: https://github.com/sighmon/mjml-rails
63
62
  licenses:
@@ -86,5 +85,4 @@ test_files:
86
85
  - test/generator_test.rb
87
86
  - test/parser_test.rb
88
87
  - test/mjml_test.rb
89
- - test/template_test.rb
90
88
  - 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