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
// 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
}
@@ -112,7 +122,7 @@ const server = new ParseServer({
112
122
});
113
123
```
114
124
115
-
##Templates
125
+
# Templates
116
126
117
127
Emails are composed using templates. A template defines the paths to its content files, for example:
118
128
@@ -131,6 +141,17 @@ There are different files for different parts of the email:
131
141
- plain-text content (`textPath`)
132
142
- HTML content (`htmlPath`)
133
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
+
134
155
# Localization
135
156
136
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.
@@ -147,7 +168,7 @@ path/
147
168
│ └── example.html // de localized file
148
169
└── de-AT/ // de-AT locale folder
149
170
│ └── example.html // de-AT localized file
150
-
````
171
+
```
151
172
152
173
Files are matched with the user locale in the following order:
153
174
1. Locale match, e.g. locale `de-AT` matches file in folder `de-AT`.
@@ -156,5 +177,5 @@ Files are matched with the user locale in the following order:
156
177
157
178
# Need help?
158
179
159
-
- Search through existing issues or open a new issue.
160
-
- 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