You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- FIX: Removed unused config parameter from docs. [#1](https://github.com/mtrezza/parse-server-api-mail-adapter/pull/1). Thanks to [mtrezza](https://github.com/mtrezza)
7
+
- NEW: Added locale to API callback. [#2](https://github.com/mtrezza/parse-server-api-mail-adapter/pull/2). Thanks to [mtrezza](https://github.com/mtrezza)
// A custom email template that can be used when sending emails from Cloud Code; the template name can be choosen freely; it is possible to add various custom templates.
78
+
// A custom email template that can be used when sending emails
79
+
// from Cloud Code; the template name can be choosen freely; it
80
+
// is possible to add various custom templates.
77
81
customEmail: {
78
82
subjectPath: './files/custom_email_subject.txt'),
79
83
textPath: './files/custom_email.txt'),
80
84
htmlPath: './files/custom_email.html'),
81
-
// Placeholders contain the values to be filled into the placeholder keys in the file content. A placeholder `{{appName}}` in the email will be replaced the value defined here.
85
+
// Placeholders are filled into the template file contents.
86
+
// For example, the placeholder `{{appName}}` in the email
87
+
// will be replaced the value defined here.
82
88
placeholders: {
83
89
appName: "ExampleApp"
84
90
},
85
-
// Extras to add to the email payload that is accessible in the `apiCallback`.
91
+
// Extras to add to the email payload that is accessible in the
// A callback that makes the Parse User accessible and allows to return user-customized placeholders that will override the default template placeholders.
96
+
// A callback that makes the Parse User accessible and allows
97
+
// to return user-customized placeholders that will override
98
+
// the default template placeholders.
90
99
placeholderCallback: async (user) => {
91
100
return {
92
101
phone: user.get('phone')
93
102
};
94
103
},
95
-
// A callback that makes the Parse User accessible and allows to return the locale of the user for template localization.
104
+
// A callback that makes the Parse User accessible and allows
105
+
// to return the locale of the user for template localization.
96
106
localeCallback: async (user) => {
97
107
return user.get('locale');
98
108
}
99
109
}
100
110
},
101
-
// The asynronous callback that contains the composed email payload to be passed on to an 3rd party API. The payload may need to be convert specifically for the API; conversion for common APIs is conveniently available in the `ApiPayloadConverter`. Below is an example for the Mailgun client.
102
-
apiCallback: async (payload) => {
111
+
// The asynronous callback that contains the composed email payload to
112
+
// be passed on to an 3rd party API and optional meta data. The payload
113
+
// may need to be converted specifically for the API; conversion for
114
+
// common APIs is conveniently available in the `ApiPayloadConverter`.
@@ -108,7 +122,7 @@ const server = new ParseServer({
108
122
});
109
123
```
110
124
111
-
##Templates
125
+
# Templates
112
126
113
127
Emails are composed using templates. A template defines the paths to its content files, for example:
114
128
@@ -127,6 +141,17 @@ There are different files for different parts of the email:
127
141
- plain-text content (`textPath`)
128
142
- HTML content (`htmlPath`)
129
143
144
+
# Placeholders
145
+
Placeholders allow to dynamically insert text into the template file content. The placeholders are filled in according to the key-value definitions returned by the placeholder callback in the adapter configuration.
146
+
147
+
This is using the [mustache](http://mustache.github.io/mustache.5.html) template syntax. The most commonly used tags are:
148
+
-`{{double-mustache}}`
149
+
150
+
The most basic form of tag; inserts text as HTML escaped by default.
151
+
-`{{{triple-mustache}}}`
152
+
153
+
Inserts text with unescaped HTML, which is required to insert a URL for example.
154
+
130
155
# Localization
131
156
132
157
Localization allows to use a specific template depending on the user locale. To turn on localization for a template, add a `localeCallback` to the template configuration.
@@ -143,7 +168,7 @@ path/
143
168
│ └── example.html // de localized file
144
169
└── de-AT/ // de-AT locale folder
145
170
│ └── example.html // de-AT localized file
146
-
````
171
+
```
147
172
148
173
Files are matched with the user locale in the following order:
149
174
1. Locale match, e.g. locale `de-AT` matches file in folder `de-AT`.
@@ -152,5 +177,5 @@ Files are matched with the user locale in the following order:
152
177
153
178
# Need help?
154
179
155
-
- Search through existing issues or open a new issue.
156
-
- Ask on StackOverflow using the tag `parse-server` and `api-mail-adapter`.
180
+
-Ask on StackOverflow using the tag [parse-server](https://stackoverflow.com/questions/tagged/parse-server).
181
+
-Search through existing issues or open a new issue.
0 commit comments