mjml-rails 2.4.1 → 2.4.2

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
  SHA1:
3
- metadata.gz: a036ea2c3f5d353750684e8cbcee10d832456db6
4
- data.tar.gz: 04e57f9864cc36334caa09c9462c9ddc337cf7e6
3
+ metadata.gz: 8e77f052d7e2a3b95f8fa4a8968e90aac1a44d6c
4
+ data.tar.gz: c0779f30b21ec71d46ceee38db0ed65562e3df65
5
5
  SHA512:
6
- metadata.gz: a601a9bf334433d410615ce01180c596556a736a37b96a3aa633a41844890f8f5f953f7e34064b2591e66afdeb783f6c8eba23e28da2e1b14a732e5c896c042d
7
- data.tar.gz: f86192ecbd69adfd2d50d537002742c9da97be51e8d578d09e331af7b1b4de7e1bda701fe66c5b4a0f08f0f39e74cb4c61457f92ee913e78ae423b6dd33b238a
6
+ metadata.gz: e8bca5a52f8d01ea38f7044c59b6b2a1d8f4ceef3b4d305a5c60bc25198267d2e579142718203afcf4bc36ae9987a24e8bf4cc9af7c1eb251aeb8042dbbfe968
7
+ data.tar.gz: 4bf757fd433358cda8ee79f33588d7297009565276ced1c01cb13f684ddfd2156ce51c9b408b6c2bf95647f10535c1cac3b1dbcf3326014997f118dd3ba63ab6
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/README.md CHANGED
@@ -65,7 +65,7 @@ Install the MJML parser (optional -g to install it globally):
65
65
  npm install -g mjml@^3.0
66
66
  ```
67
67
 
68
- NOTE: there seems to be a [path related bug](https://github.com/mjmlio/mjml/issues/501) with ```mjml 3.2.0```, so perhaps use ```npm install -g mjml@3.1.1```.
68
+ Note that you'll need at least Node.js version 6 for MJML to function properly.
69
69
 
70
70
  If you're using ```:haml``` or any other Rails template language, create an initializer to set it up:
71
71
 
@@ -90,6 +90,74 @@ gem 'mjml-rails', '2.2.0'
90
90
 
91
91
  [Hugo Giraudel](https://twitter.com/hugogiraudel) wrote a post on [using MJML in Rails](http://dev.edenspiekermann.com/2016/06/02/using-mjml-in-rails/).
92
92
 
93
+ ## Using Email Layouts
94
+
95
+ Mailer:
96
+ ```ruby
97
+ # mailers/foo_mailer.rb
98
+ class MyMailer < ActionMailer::Base
99
+ layout "default"
100
+
101
+ def mail_template(template_name, recipient, subject, **params)
102
+ mail(
103
+ to: recipient.email,
104
+ from: ENV["MAILER_FROM"],
105
+ subject: subject
106
+ ) do |format|
107
+ format.mjml { render template_name, locals: { recipient: recipient }.merge(params) }
108
+ end
109
+ end
110
+
111
+ # this function is called to send the email
112
+ def foo(item, user)
113
+ mail_template(
114
+ "foo_bar",
115
+ user,
116
+ "email subject",
117
+ request: item
118
+ )
119
+ end
120
+ end
121
+ ```
122
+
123
+ Email layout:
124
+ ```html
125
+ <!-- views/layouts/default.mjml -->
126
+ <mjml>
127
+ <mj-body>
128
+ <mj-container>
129
+ <%= yield %>
130
+ </mj-container>
131
+ </mj-body>
132
+ </mjml>
133
+ ```
134
+
135
+ Email view:
136
+ ```html
137
+ <!-- views/my_mailer/foo_bar.mjml.erb -->
138
+ <%= render partial: "to", formats: [:html], locals: { name: recipient.name } %>
139
+
140
+ <mj-section>
141
+ <mj-column>
142
+ <mj-text>
143
+ Hello <%= recipient.name %>!
144
+ </mj-text>
145
+ </mj-column>
146
+ </mj-section>
147
+ ```
148
+
149
+ Email partial:
150
+ ```html
151
+ <!-- views/my_mailer/_to.mjml -->
152
+ <mj-section>
153
+ <mj-column>
154
+ <mj-text>
155
+ <%= name %>,
156
+ </mj-text>
157
+ </mj-column>
158
+ </mj-section>
159
+ ```
160
+
93
161
  ## Sending Devise user emails
94
162
 
95
163
  If you use [Devise](https://github.com/plataformatec/devise) for user authentication and want to send user emails with MJML templates, here's how to override the [devise mailer](https://github.com/plataformatec/devise/blob/master/app/mailers/devise/mailer.rb):
data/lib/mjml.rb CHANGED
@@ -25,7 +25,8 @@ module Mjml
25
25
  mjml_bin = File.join(`npm bin`.chomp, 'mjml')
26
26
  return mjml_bin if check_version(mjml_bin)
27
27
 
28
- raise RuntimeError, "Couldn't find the MJML binary.. have you run $ npm install mjml?"
28
+ puts "Couldn't find the MJML binary.. have you run $ npm install mjml?"
29
+ nil
29
30
  end
30
31
 
31
32
  BIN = discover_mjml_bin
data/lib/mjml/parser.rb CHANGED
@@ -5,6 +5,7 @@ module Mjml
5
5
  #
6
6
  # @param input [String] The string to transform in html
7
7
  def initialize input
8
+ raise "Couldn't find the MJML binary.. have you run $ npm install mjml?" unless mjml_bin
8
9
  file = File.open(in_tmp_file, 'w')
9
10
  file.write(input)
10
11
  file.close
@@ -78,4 +79,4 @@ module Mjml
78
79
  Mjml::BIN
79
80
  end
80
81
  end
81
- end
82
+ end
data/lib/mjml/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Mjml
2
- # Version number matches MJML.io version
3
- VERSION = "2.4.1"
2
+ # Version number no longer matches MJML.io version
3
+ VERSION = "2.4.2"
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: 2.4.1
4
+ version: 2.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simon Loffler
@@ -31,7 +31,7 @@ cert_chain:
31
31
  5hPZOkUdP3egZ1xAHeFIOhTIaOJezjUEDQVattPkgwl25+Q2EXJ+5ehDU86v+lxH
32
32
  E9hMwkxwQntg0fKVFbnVMOg2itaj8fJ7
33
33
  -----END CERTIFICATE-----
34
- date: 2017-01-19 00:00:00.000000000 Z
34
+ date: 2017-05-02 00:00:00.000000000 Z
35
35
  dependencies: []
36
36
  description: Render MJML + ERb template views in Rails
37
37
  email: sighmon@sighmon.com
metadata.gz.sig CHANGED
Binary file