react-email-rails 0.6.0 → 0.6.1
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 +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +8 -0
- data/lib/react_email_rails/action_mailer.rb +12 -5
- data/lib/react_email_rails/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4755984b895a6aa5f220079065da541f8b8da23dc905095fb5cae48471fb2096
|
|
4
|
+
data.tar.gz: 66568a9bd36727d453904f765b2eb73b3aff4b8335b59de57d34933f1e4a4b8a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d5b407fd84acd1a1f162fe412f5d1ee611a0fdd095a2923b2a38ef2c63e366023a513fa26c09453fbbc1c9821c3681bb2838713dfdcf463dd8c767cdc5375b5c
|
|
7
|
+
data.tar.gz: 81f890f4900c9dae7631073bb68b66941642456fc895a81a3a78620f7e719df506ead6dcf5fddc38ab746182f544054f243f111968839e99e512e1a89eb0fe4b
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.6.1
|
|
4
|
+
|
|
5
|
+
- Fix `react:` rendering — and the `mailer`/`message` props — being skipped for actions that opt in through a class-level `default react: true` rather than a per-`mail` `react:` option. `mail` now resolves `react` (in any form: `true`, a component string, or a prop hash) from the mailer's `default`, a per-action `react: false` opts back out, and the internal `react`/`props`/`deep_merge` options never leak onto the message as email headers.
|
|
6
|
+
|
|
3
7
|
## 0.6.0
|
|
4
8
|
|
|
5
9
|
- Every `react:` email now receives `mailer` and `message` props, mirroring Action Mailer's `mailer`/`message` ERB view helpers. Rendering now happens after Action Mailer assigns headers, so `message` includes subject, addressing, and default `from`/`reply_to` values. Per-mail and shared props win on conflict, serializers whose `as_json` returns a Hash receive the context, and collection props keep their original shape. The npm package exports matching `Mailer`/`Message` TypeScript types.
|
data/README.md
CHANGED
|
@@ -240,6 +240,14 @@ end
|
|
|
240
240
|
|
|
241
241
|
Action Mailer's framework assigns, including `params` and `rendered_format`, are excluded from instance props.
|
|
242
242
|
|
|
243
|
+
To make React the default for every action, set `default react: true` on the mailer (or `ApplicationMailer`). Each `mail` call then renders the inferred component without repeating `react: true`, and a single action can opt back out with `react: false`:
|
|
244
|
+
|
|
245
|
+
```ruby
|
|
246
|
+
class ApplicationMailer < ActionMailer::Base
|
|
247
|
+
default react: true
|
|
248
|
+
end
|
|
249
|
+
```
|
|
250
|
+
|
|
243
251
|
### Explicit Components
|
|
244
252
|
|
|
245
253
|
Pass a component name when the mailer action and component path do not line up:
|
|
@@ -28,12 +28,15 @@ module ReactEmailRails::ActionMailer
|
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
def mail(headers = {}, &block)
|
|
31
|
-
return super unless headers.is_a?(Hash)
|
|
31
|
+
return super unless headers.is_a?(Hash)
|
|
32
|
+
return super if headers.empty? && @_mail_was_called
|
|
32
33
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
react = headers.key?(:react) ? headers[:react] : compute_default(self.class.default[:react])
|
|
35
|
+
return super unless react
|
|
36
|
+
|
|
37
|
+
props = headers[:props]
|
|
38
|
+
deep_merge = headers[:deep_merge]
|
|
39
|
+
headers = headers.except(:react, :props, :deep_merge)
|
|
37
40
|
|
|
38
41
|
component, resolved_props = ReactEmailRails::PropsResolver.new(self).resolve(react, props)
|
|
39
42
|
resolved_props = ReactEmailRails::SharedProps.new(self).merge_into(
|
|
@@ -53,6 +56,10 @@ module ReactEmailRails::ActionMailer
|
|
|
53
56
|
|
|
54
57
|
private
|
|
55
58
|
|
|
59
|
+
def assign_headers_to_message(message, headers)
|
|
60
|
+
super(message, headers.except(:react, :props, :deep_merge))
|
|
61
|
+
end
|
|
62
|
+
|
|
56
63
|
def react_email_render(component, props)
|
|
57
64
|
props = ReactEmailRails::MailerContext.new(self).merge_into(props)
|
|
58
65
|
render_options = ReactEmailRails.configuration.resolve_render_options(self)
|