Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

premailer-api

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

premailer-api

Node wrapper for the Premailer API (premailer.dialect.ca/api)

  • 1.0.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.4K
increased by410.68%
Maintainers
1
Weekly downloads
 
Created
Source

node-premailer

A simple api wrapper for http://premailer.dialect.ca, a great tool for inlining css before you send an email.

node-premailer simplifies api integration by calling the Premailer API to inline css styles (and other options such as removing comments, classes and ids), then retrieving the generated html and text from their respective URLs before passing them to your callback.

Install

  npm install premailer-api

Or from source:

  git clone git://github.com/JedWatson/node-premailer.git 
  cd node-premailer
  npm link

Usage

var premailer = require('premailer-api');

var emailTemplate = '
  <html>
    <head>
      <title>My Email</title>
      <style type="text/css">
        a { color: #336699; }
      </style>
    </head>
    <body>
      Styles inlined with 
      <a href="http://premailer.dialect.ca">Premailer</a> via 
      <a href="https://github.com/JedWatson/node-premailer">node-premailer</a>.
    </body>
  <html>';

premailer.prepare({html: emailTemplate }, function(err, email) {
  res.send(email.html);
});

Options

  • premailerAPI (string) The URL of the premailer API. If you're running your own, replace this. Defaults to http://premailer.dialect.ca/api/0.1/documents
  • html (string) The html of the email to parse and inline styles.
  • url (string) The url of the email to fetch then parse and inline styles.
  • fetchHTML (boolean) Whether to fetch the parsed HTML (you'll usually want this). Defaults to true.
  • fetchText (boolean) Whether to fetch the auto-generated text version (disable this if you are providing your own). Defaults to true.
  • See http://premailer.dialect.ca/api for full list of options. All options have aliases for node.js style variable names.
    • adapter
    • baseUrl || base_url
    • lineLength || line_length
    • linkQueryString || link_query_string
    • preserveStyles || preserve_styles
    • removeIds || remove_ids
    • removeClasses || remove_classes
    • removeComments || remove_comments

License and Credits

MIT Licensed. Copyright Jed Watson 2012.

A big thankyou to Dialect for Premailer, and for making the API freely available.

There's also a web version available here: http://premailer.dialect.ca

And you can check out the source code for Premailer itself here: https://github.com/alexdunae/premailer/

Keywords

FAQs

Package last updated on 27 Jun 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc