CSS is ignored if you don’t have a text.ejs #12

natesilva opened this Issue Oct 23, 2012 · 2 comments


None yet

3 participants


If your template doesn’t have a text.ejs file, then your style.css is ignored.

My understanding is that style.css is used to add inline styles to the HTML version of your e-mail (that is, html.ejs), so it should work regardless of whether text.ejs is present or not.

To reproduce

  • Create a project. npm install email-templates.
  • Create a directory called templates and copy the entire pasta-dinner example template there (including html.ejs, text.ejs and style.css).
  • Run the following app:
var path           = require('path')
  , templatesDir   = path.join(__dirname, 'templates')
  , emailTemplates = require('email-templates');

emailTemplates(templatesDir, function(err, template) {
  template('pasta-dinner', {pasta: 'Spaghetti'}, function(err, html, text) {
    console.log('html is:', html);
  • Note that everything works as expected, and the <h1> style is inlined.
  • Now delete templates/pasta-dinner/text.ejs.
  • Run the app again.

Expected results

The HTML output should be the same as before, including the inlined <h1> style.

Acutal results

Styles from style.css are not present.


chovy commented Oct 23, 2012

I believe it sends multipart/alternative emails, which requires a text version. You can generate a text version from html if you don't want to explicity define a text.ejs.

      from: 'Spicy Meatball <spicy.meatball@spaghetti.com>',
      to: locals.email,
      subject: 'Mangia gli spaghetti con polpette!',
      html: html,
      generateTextFromHTML: true

Hi @chovy,

I discovered the problem while using generateTextFromHTML. But by that time, you’ve already called template(…) and it’s already generated your HTML, ignoring style.css.

My workaround was to create a blank text.ejs.

But it should use your style.css when generating the HTML, even if you have not created a text.ejs file, blank or not.


@niftylettuce niftylettuce pushed a commit that closed this issue Mar 4, 2013
@bratchenko bratchenko fixed ignoring styles.css without text.ejs
I believe it fixes #12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment