Applies external CSS stylesheets to HTML emails to work with Gmail.
npm install stylinerstyle="" attributes in an HTML document.
tags). Unfortunately, though, you'll still need to use s to get complex layout.
You can also use advanced features ("dynamic rules") like :hover selectors or media queries, and Styliner will leave them in a tag. This way, you can build interactive emails that will light up when viewed in an email client that supports tags, while still maintaining Gmail support.
In effect, you get graceful degradation for your email designs.
Usage
Styliner uses the Q promise library.
``javascript
var styliner = new Styliner(baseDir, { options });
styliner.processHTML(htmlSource, directory)
.then(function(source) { ... });
//Pass filePath to processHTML
styliner.parseFile(filePath)
.then(function(source) { ... });
`
The baseDir parameter specifies the base directory for relative paths. When processing an HTML source file, you can optionally specify a directory for that source, and any relative paths within the file will be treated as relative to that directory (instead of relative to the Styliner instance's baseDir).
The processHTML method returns a Q promise of the inlined HTML source.
You can pass an options hash as the second parameter to the Styliner constructor with the following options: (all options default to false):
- compact: true
- True to minify all output. This option removes all extraneous whitespace from the generated HTML (including any remaining inline stylesheets)
- noCSS: true
- True to not emit