Skip to content

Commit b7e7a42

Browse files
committed
Add some documentation around postmark-templates.
And its constituent and related tasks – `postmark-templates-upload`, `postmark-templates-output`, `postmark-templates-parse`, `postmark-templates-from-targets`, and `postmark-templates-from-file`. Per #3 (comment).
1 parent ee632f2 commit b7e7a42

File tree

2 files changed

+187
-10
lines changed

2 files changed

+187
-10
lines changed

Gruntfile.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ module.exports = function (grunt) {
3333

3434
"postmark-templates-upload": {
3535
options: {
36-
ephemeralUploadResultsProperty: "<%= config.templates && config.templates.ephemeralUploadResultsProperty %>"
36+
ephemeralUploadResultsProperty: "<%= config.templates && config.templates.ephemeralUploadResultsProperty %>",
37+
serverToken: "<%= secret.postmark.server_token %>"
3738
},
3839
test_email: {
3940
name: "testing-postmark-templates-js1-" + new Date().valueOf(),

README.md

Lines changed: 185 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,35 +25,34 @@ You'll need to add a [`config.json`](https://github.com/wildbit/mailmason/wiki/G
2525
## Postmark task
2626
_Run this task with the `grunt postmark` command._
2727

28-
## Options
28+
### Options
2929

30-
31-
### serverToken
30+
#### serverToken
3231
Your server token can be found on your server’s credentials page on [Postmark’s](http://postmarkapp.com) app.
3332

3433
Type: `String`
3534

3635

37-
### from
36+
#### from
3837
This is the from address you are using to send the email. This must be a confirmed address that's set up on [Postmark’s](http://postmarkapp.com) sender signatures.
3938

4039
Type: `String`
4140

4241

43-
### to
42+
#### to
4443
The address you’re sending to.
4544

4645
Type: `String`
4746

4847

49-
### subject
48+
#### subject
5049

5150
Type: `String`
5251

5352

54-
## Examples
53+
### Examples
5554

56-
### Options specified through target
55+
#### Options specified through target
5756

5857
```javascript
5958
grunt.initConfig({
@@ -69,7 +68,7 @@ grunt.initConfig({
6968
});
7069
```
7170

72-
### Specify options through targets or globally
71+
#### Specify options through targets or globally
7372
Options specified through a target will always take precedence over global options.
7473

7574
```javascript
@@ -91,4 +90,181 @@ grunt.initConfig({
9190
}
9291
}
9392
});
93+
```
94+
95+
## Postmark templates task
96+
_Run this task with the `grunt postmark-templates` command._
97+
98+
The `postmark-templates` task is an alias of the `postmark-templates-from-targets` task which is itself a two stepped task – `postmark-templates-upload` followed by `postmark-templates-output`.
99+
100+
`postmark-templates` (`postmark-templates-from-targets`) is intended for programmatic usage from other grunt tasks.
101+
102+
### `postmark-templates-upload` Targets
103+
104+
#### name
105+
The name of your template.
106+
107+
Type: `String`
108+
109+
110+
#### subject
111+
The subject line of your template.
112+
113+
Type: `String`
114+
115+
#### htmlSrc
116+
A path to the generated HTML for your template. *Not used if `htmlBody` is specified.*
117+
118+
Type: `String`
119+
120+
121+
#### textSrc
122+
A path to the generated plain text for your template. *Not used if `textBody` is specified.*
123+
124+
Type: `String`
125+
126+
#### htmlBody
127+
The generated HTML content of your template. *Not required if `htmlSrc` is specified.*
128+
129+
Type: `String`
130+
131+
132+
#### textBody
133+
The generated plain text content of your template. *Not required if `textSrc` is specified.*
134+
135+
Type: `String`
136+
137+
138+
### `postmark-templates-upload` Options
139+
140+
#### serverToken
141+
Your server token can be found on your server’s credentials page on [Postmark’s](http://postmarkapp.com) app.
142+
143+
Type: `String`
144+
145+
146+
#### ephemeralUploadResultsProperty
147+
This is the name of a temporary grunt task configuration property used to communicate the upload results between `postmark-templates-upload` and `postmark-templates-output` without having to write a temporary file. **This should be the same value as `ephemeralUploadResultsProperty` for `postmark-templates-output`.**
148+
149+
Type: `String`
150+
151+
152+
### `postmark-templates-output` Options
153+
154+
#### outputFile
155+
The name of a file to output the results of the upload to Postmark.
156+
157+
Type: `String`
158+
159+
160+
#### cleanOutput
161+
If `true`, do not export `htmlBody`, `htmlSrc`, `textBody` or `textSrc` in the specified `outputFile`.
162+
163+
Type: `Boolean`
164+
165+
166+
#### ephemeralUploadResultsProperty
167+
This is the name of a temporary grunt task configuration property used to communicate the upload results between `postmark-templates-upload` and `postmark-templates-output` without having to write a temporary file. **This should be the same value as `ephemeralUploadResultsProperty` for `postmark-templates-upload`.**
168+
169+
Type: `String`
170+
171+
172+
### Example
173+
174+
```javascript
175+
grunt.initConfig({
176+
'postmark-templates-upload': {
177+
options: {
178+
serverToken: 'POSTMARK_API_TEST',
179+
ephemeralUploadResultsProperty: 'temp'
180+
},
181+
test_email: {
182+
name: 'testing-postmark-templates-js1',
183+
subject: 'Testing grunt-postmark-templates',
184+
htmlSrc: 'test/email.html',
185+
textSrc: 'test/email.txt'
186+
},
187+
test_email_inline_body: {
188+
name: 'testing-postmark-templates-js3',
189+
subject: 'Testing grunt-postmark-templates (inline body)',
190+
htmlBody: '<html><body><h1>Another email test</h1></body></html>',
191+
textBody: 'Hello from grunt-postmark-templates\n'
192+
}
193+
},
194+
'postmark-templates-output': {
195+
options: {
196+
cleanOutput: true,
197+
outputFile: 'templates.json',
198+
ephemeralUploadResultsProperty: 'temp'
199+
}
200+
}
201+
});
202+
```
203+
204+
## Postmark templates (from file) task
205+
_Run this task with the `grunt postmark-templates-from-file` command._
206+
207+
The `postmark-templates-from-file` task invokes the `postmark-templates` task with targets read from a JSON file (via `postmark-templates-parse`).
208+
209+
This task is intended for standalone, manual usage.
210+
211+
212+
### `postmark-templates-parse` Options
213+
214+
#### inputFile
215+
The name of a file that specifies templates for uploading to Postmark. These templates take the same shape as defined by `postmark-templates-upload`. This should usually be the same value as `outputFile` for `postmark-templates-output`.
216+
217+
Type: `String`
218+
219+
220+
### Example
221+
222+
In your `Gruntfile`:
223+
224+
```javascript
225+
grunt.initConfig({
226+
'postmark-templates-parse': {
227+
options: {
228+
inputFile: 'templates.json'
229+
}
230+
},
231+
'postmark-templates-upload': {
232+
options: {
233+
serverToken: 'POSTMARK_API_TEST',
234+
ephemeralUploadResultsProperty: 'temp'
235+
}
236+
},
237+
'postmark-templates-output': {
238+
options: {
239+
cleanOutput: true,
240+
outputFile: 'templates.json',
241+
ephemeralUploadResultsProperty: 'temp'
242+
}
243+
}
244+
});
245+
```
246+
247+
In the file specified by `inputFile`, in this case, `templates.json`:
248+
249+
```json
250+
{
251+
"test_email": {
252+
"name": "testing-postmark-templates-js1",
253+
"subject": "Testing grunt-postmark-templates",
254+
"htmlSrc": "test/email.html",
255+
"textSrc": "test/email.txt"
256+
},
257+
"test_email_again": {
258+
"name": "testing-postmark-templates-js2",
259+
"subject": "Testing grunt-postmark-templates (again)",
260+
"htmlSrc": "test/email.html",
261+
"textSrc": "test/email.txt"
262+
},
263+
"test_email_inline_body": {
264+
"name": "testing-postmark-templates-js3",
265+
"subject": "Testing grunt-postmark-templates (inline body)",
266+
"htmlBody": "<html><body><h1>Another email test</h1></body></html>",
267+
"textBody": "Hello from grunt-postmark-templates\n"
268+
}
269+
}
94270
```

0 commit comments

Comments
 (0)