effective_email_templates 1.6.0 → 1.7.0

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: b61c8d36a7412e96eef80c03fb75480a8da1de2156b67587d7fb88b24e85e7bd
4
- data.tar.gz: dca4e0ccafebf84a7b19f78797854fbb98d1547e18d7a593b408f69ef6e3658c
3
+ metadata.gz: 8d32e71af524fb3658debbf8210a4239b4bbd98f7a806f0a743735e62bc135dc
4
+ data.tar.gz: f6064f01a1a679b3c4bf1abca99222ab4ba191d4bb0ee16a1ac23ddad644c368
5
5
  SHA512:
6
- metadata.gz: 65426e9861152f2794e2817f70983fed0c9c918f3c24fd819f92aa1353fc28d122c4573b0c4e68ce8953d7dcb7ff5de170d38b6eab6969c71d77fa0ad6b0d75c
7
- data.tar.gz: 9754add70dac2088baf9ee4c8b2fdb4e9f3f290043db9a9af358c323655e4f11d7f6aa0073506f4fe11b421c6f04fc650dd31ce58175d298cd1cbeb7664b4d57
6
+ metadata.gz: 360328a697866d2d802d7c882bcfbd9c0be6e148c0b6d98114417088af72b9ea74cc935d275b6396a8be64becd88749536f491b1cfcb0f953e8ab1c739ba276e
7
+ data.tar.gz: 5cad8e018ad138e6050278c36e39a69a631a06773bc8d87aeee9986a96b56de9ab3f491198634eea514126f30241a0536b2b8ccceb9721f5e6a7da928e7f0b63
@@ -15,10 +15,11 @@ module EffectiveEmailTemplatesMailer
15
15
 
16
16
  # Parse subject content if explicitly given
17
17
  # Otherwise the :subject key is a default and should be ignored in favor of the email template subject instead
18
- subject = assigns.delete(:subject)
19
- subject ||= (headers[:subject] || headers['subject']) if (headers[:custom_subject] || headers['custom_subject'])
18
+ subject = assigns.delete(:subject) || headers[:subject] || headers['subject']
20
19
  email_template.subject = subject if subject.present?
21
20
 
21
+ # If the body or subject are nil, they will be populated from the email_template
22
+
22
23
  # Add any _url helpers
23
24
  assigns = route_url_assigns(email_template, assigns).merge(assigns)
24
25
 
@@ -26,7 +27,20 @@ module EffectiveEmailTemplatesMailer
26
27
  rendered = email_template.render(assigns)
27
28
 
28
29
  # Merge any other passed values
29
- merged = rendered.merge(headers.except(:body, :subject, :custom_subject, 'body', 'subject', 'custom_subject'))
30
+ merged = rendered.merge(headers.except(:body, :subject, 'body', 'subject'))
31
+
32
+ # Finalize the subject_for Proc
33
+ if respond_to?(:subject_for) # EffectiveResourcesMailer
34
+ if (prefix = EffectiveResources.mailer_subject_prefix_hint).present?
35
+ subject = subject_for(action_name, merged[:subject], email_template, merged)
36
+
37
+ if subject.start_with?("#{prefix}#{prefix}") || subject.start_with?("#{prefix} #{prefix}")
38
+ subject = subject.sub(prefix, '')
39
+ end
40
+
41
+ merged[:subject] = subject
42
+ end
43
+ end
30
44
 
31
45
  super(merged)
32
46
  end
@@ -23,6 +23,7 @@ module Effective
23
23
 
24
24
  before_validation do
25
25
  self.content_type ||= CONTENT_TYPES.first
26
+ self.from ||= EffectiveEmailTemplates.mailer_froms.first
26
27
  end
27
28
 
28
29
  validates :body, liquid: true
@@ -4,11 +4,15 @@
4
4
  - if EffectiveEmailTemplates.select_content_type
5
5
  = f.select :content_type, Effective::EmailTemplate::CONTENT_TYPES
6
6
 
7
- = f.select :from, EffectiveEmailTemplates.mailer_froms, hint: 'Please contact us to add additional sender addresses.'
7
+ = f.select :from, mailer_froms_collection(), hint: 'Please contact us to add additional sender addresses. Please refresh the page if this from address looks weird.'
8
8
  = f.text_field :cc
9
9
  = f.text_field :bcc
10
10
 
11
- = f.text_field :subject, hint: 'The subject of your email'
11
+ - prefix_hint = EffectiveResources.mailer_subject_prefix_hint.to_s.strip.presence
12
+
13
+ = f.text_field :subject,
14
+ hint: (prefix_hint ? "The subject of your email. It will be automatically prefixed with #{prefix_hint}." : 'The subject of your email')
15
+
12
16
  = f.text_area :body, hint: 'The content of your email template', rows: 10
13
17
 
14
18
  .card
@@ -1,3 +1,3 @@
1
1
  module EffectiveEmailTemplates
2
- VERSION = '1.6.0'.freeze
2
+ VERSION = '1.7.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_email_templates
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-10-25 00:00:00.000000000 Z
11
+ date: 2023-10-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails