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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 58c530e15903cfef6a41754880409a7adad3a3e0
4
- data.tar.gz: 6985b4528de6935bf2947f2cf9cdba91ca82b72a
3
+ metadata.gz: 3ff92b3118bdf891ae8dbea21652e1aabf28db6d
4
+ data.tar.gz: 1078cd1690c20cc325b35fd615ddb6531313cd13
5
5
  SHA512:
6
- metadata.gz: f689b6a2f98a7ca1762e23fe85cda2624b513f12d40a6f0b8fe913d67c80d9f0e0c9f3ad19544912cfaded2cd8aa9639421566665b61b3e5cb279d86cef14633
7
- data.tar.gz: 67de90735d5116071069d340854248aa6e9d729e9a973a2112dabb3ed53555ed94e571f079eb13afa13140d4e8f1f0c2b06ecc0357808c6abe9a4aed1aa19f84
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 mail(headers, &block)
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[:body] = Mjml.template(content)
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
- super(headers, &block)
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
@@ -1,3 +1,3 @@
1
1
  module Mjml
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mjml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - MQuy