Usage
Generate a plaintext version for all your email templates by adding aplaintext key to your templates source in config.js:
config.js
Custom path
Set theplaintext key to be a directory path to output plaintext files to a custom location. Plaintext files will be output relative to the build.output.path folder.
config.js
output.path and output.extension keys:
config.js
The
path option must be a directory path, otherwise a single plaintext file will be generated for all of your emails.Front Matter
Generate a plaintext version for a specific Template by enabling it in its Front Matter:emails/example.html
.txt file will be output at the same location with the compiled Template.
You may of course set plaintext to a custom path in Front Matter as well.
Using a file path for plaintext in Front Matter will output that file at the specified location relative to the project root:
emails/example.html
dist/brand/plain.txt relative to your project root:
build.output.path folder instead, and will use the same name as the Template:
emails/example.html
Permalink
If you’re using thepermalink Front Matter key in your Template, Maizzle will output the .txt file at that location:
emails/example.html
example/email.txt will be generated.
No matter what you set plaintext to in Front Matter in this case, as long as it’s a truthy value the plaintext file will be output at the location specified by permalink, using the exact same filename but with the .txt extension.
Customization
By default, the plaintext generator in Maizzle uses most default options fromstring-strip-html, with this exception:
plaintext object in your config.js to overwrite any of the defaults from string-strip-html.
config.js
With the config above, Maizzle will output plaintext versions for all Templates.
Front Matter override
Usingplaintext: true like in the Front Matter example will override your plaintext config object if you have it defined in config.js like above.
If you need to control string-strip-html options when generating plaintext for a specific Template, you need to use enabled: true.
You basically add the options object to the Template’s Front Matter:
<plaintext> tag
Output content only in the plaintext version:emails/example.html
<not-plaintext> tag
You may also discard content from the plaintext version while preserving it in the HTML, with the help of the<not-plaintext> tag:
emails/example.html
API
You may render an HTML string to plaintext in your application with the help of theplaintext() method. The custom tags, like <plaintext>, are also supported.
app.js
app.js