mjml 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mjml/mailer.rb +31 -4
- data/lib/mjml/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ff92b3118bdf891ae8dbea21652e1aabf28db6d
|
4
|
+
data.tar.gz: 1078cd1690c20cc325b35fd615ddb6531313cd13
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 642165a8c23267eb6af96688a0f4cfbaab33ca7076a562a5a86d67164629172e7f9e6dfe68c5108803e2bcb1b2443128fa721a837c7a29320fe2a1fc5bf82475
|
7
|
+
data.tar.gz: c9d3ec46da48179a6c1ca543ed2d16c22f6174529980bf69337c012b1950596a60c1d7c50856613d1f57765e0be895e4eddf06fdb2e3f180f0f127751cf08364
|
data/lib/mjml/mailer.rb
CHANGED
@@ -1,13 +1,40 @@
|
|
1
1
|
module Mjml
|
2
2
|
module Mailer
|
3
|
-
def
|
3
|
+
def mjml(headers, &block)
|
4
4
|
scope = Mjml::Scope.new(self, headers[:template_variables])
|
5
|
-
content = _layout ? mjml_layout_content(headers, scope) : mjml_template_content(headers, scope)
|
6
5
|
|
7
|
-
headers[:
|
6
|
+
headers[:subject] ||= I18n.t("mailers.#{mailer_name}.#{action_name}.subject")
|
7
|
+
headers[:template_name] ||= action_name
|
8
|
+
headers[:template_path] ||= "#{Dir.pwd}/app/views/mailers/#{mailer_name}"
|
9
|
+
headers[:body] = mjml_content(headers, scope)
|
8
10
|
headers[:content_type] = "text/html"
|
9
11
|
|
10
|
-
|
12
|
+
mail(headers, &block)
|
13
|
+
end
|
14
|
+
|
15
|
+
def mailer_name
|
16
|
+
self.class.name.underscore.sub(/_mailer$/, '')
|
17
|
+
end
|
18
|
+
|
19
|
+
def t(pharse, args = {})
|
20
|
+
if pharse =~ /\A\./
|
21
|
+
I18n.t("mailers.#{mailer_name}.#{action_name}#{pharse}", args)
|
22
|
+
else
|
23
|
+
super
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def mjml_content(headers, scope)
|
30
|
+
content =
|
31
|
+
if _layout
|
32
|
+
mjml_layout_content(headers, scope)
|
33
|
+
else
|
34
|
+
mjml_template_content(headers, scope)
|
35
|
+
end
|
36
|
+
|
37
|
+
Mjml.template(content)
|
11
38
|
end
|
12
39
|
|
13
40
|
def mjml_layout_content(headers, scope)
|
data/lib/mjml/version.rb
CHANGED