effective_email_templates 1.5.0 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b61c8d36a7412e96eef80c03fb75480a8da1de2156b67587d7fb88b24e85e7bd
|
4
|
+
data.tar.gz: dca4e0ccafebf84a7b19f78797854fbb98d1547e18d7a593b408f69ef6e3658c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65426e9861152f2794e2817f70983fed0c9c918f3c24fd819f92aa1353fc28d122c4573b0c4e68ce8953d7dcb7ff5de170d38b6eab6969c71d77fa0ad6b0d75c
|
7
|
+
data.tar.gz: 9754add70dac2088baf9ee4c8b2fdb4e9f3f290043db9a9af358c323655e4f11d7f6aa0073506f4fe11b421c6f04fc650dd31ce58175d298cd1cbeb7664b4d57
|
@@ -9,21 +9,26 @@ module EffectiveEmailTemplatesMailer
|
|
9
9
|
|
10
10
|
assigns = (@assigns || {})
|
11
11
|
|
12
|
-
# Parse
|
12
|
+
# Parse body content if given
|
13
13
|
body = assigns.delete(:body) || headers[:body] || headers['body']
|
14
14
|
email_template.body = body if body.present?
|
15
15
|
|
16
|
-
#
|
16
|
+
# Parse subject content if explicitly given
|
17
|
+
# Otherwise the :subject key is a default and should be ignored in favor of the email template subject instead
|
17
18
|
subject = assigns.delete(:subject)
|
19
|
+
subject ||= (headers[:subject] || headers['subject']) if (headers[:custom_subject] || headers['custom_subject'])
|
18
20
|
email_template.subject = subject if subject.present?
|
19
21
|
|
20
22
|
# Add any _url helpers
|
21
23
|
assigns = route_url_assigns(email_template, assigns).merge(assigns)
|
22
24
|
|
23
|
-
# Render from the template, possibly with updated body
|
25
|
+
# Render from the template, possibly with updated body and subject
|
24
26
|
rendered = email_template.render(assigns)
|
25
27
|
|
26
|
-
|
28
|
+
# Merge any other passed values
|
29
|
+
merged = rendered.merge(headers.except(:body, :subject, :custom_subject, 'body', 'subject', 'custom_subject'))
|
30
|
+
|
31
|
+
super(merged)
|
27
32
|
end
|
28
33
|
|
29
34
|
private
|
@@ -53,7 +53,8 @@ module EffectiveEmailTemplates
|
|
53
53
|
content.gsub(match[1], '').strip if match
|
54
54
|
end
|
55
55
|
|
56
|
-
from = froms.find { |from| from.include?(attributes['from']) }
|
56
|
+
from = froms.find { |from| from.include?(attributes['from']) } if attributes['from'].present?
|
57
|
+
from ||= froms.first
|
57
58
|
|
58
59
|
email_template.assign_attributes(attributes)
|
59
60
|
email_template.assign_attributes(from: from)
|