Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for bgcolor #14

Open
alexanderjakob opened this issue Jun 23, 2016 · 8 comments
Open

Support for bgcolor #14

alexanderjakob opened this issue Jun 23, 2016 · 8 comments

Comments

@alexanderjakob
Copy link

Hey guys,

first: I really thank you for developing such a tool - great work!

Now, I came to a point I needed support for the bgcolor-attribut due to problems in different email "browsers".

Is there a possibility to add a "bgcolor=COLOR" attribute when having a "background-color" attribute in my css file?

@jeremypeter
Copy link
Contributor

Look like the new version of Juice supports it https://github.com/Automattic/juice/blob/master/client.js#L23 so we'll have to up our version

@jeremypeter
Copy link
Contributor

@aj1991 version 1.4.0 now supports Juice 2.0. So you can do what you want using setting the following :

juice : {
  applyAttributesTableElements: true
}

@HowardChris
Copy link

Was there a result for this, I have been looking into how to get it working. Does it require a separate file to tell it to take the CSS and apply it as the HTML attribute?

@jeremypeter
Copy link
Contributor

@HowardChris You'll have to set the applyAttributesTableElements Juice option to true. Here's kind of a working example:

index.html

<!DOCTYPE html>
<html>
<head>
  <style>
    table { background-color: red; }
  </style>
</head>
<body>
  <table> .... </table>
</body>
</html>

main.js

var EmailBuilder = require('email-builder-core');
var emailBuilder = new EmailBuilder({ 
  juice: {
    applyAttributesTableElements: true
  }
});

output.html

<!DOCTYPE html>
<html>
<head>
</head>
<body>
  <table style="background-color: red;" bgcolor="red"> .... </table>
</body>
</html>

@HowardChris
Copy link

@jeremypeter thanks for the info, I will see if I can add this into my current workflow. Still learning grunt to try and automate my emails but configuring the Gruntfile.js is still a learning curve

@HowardChris
Copy link

HowardChris commented Jun 9, 2017

Hi @jeremypeter

Do you know if there is also an option to not strip out the self-closing tags,

When compiled it is removing them.

For exmaple <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> becomes <meta http-equiv="Content-Type" content="text/html; charset=utf-8">

Any information is appreciated.

Thanks,
Chris

@jeremypeter
Copy link
Contributor

@HowardChris
Set the options.cheerio.xmlMode to true

var EmailBuilder = require('email-builder-core');
var emailBuilder = new EmailBuilder({ 
  juice: {
    applyAttributesTableElements: true
  },
  cheerio: {
    xmlMode: true
  }
});

@HowardChris
Copy link

Hi @jeremypeter thanks for all your help on this I really appreciate it, I got those options added and are now working perfect

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants